ChessUSA.com TalkChess.com
Hosted by Your Move Chess & Games
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

IDE help
Goto page 1, 2  Next
 
Post new topic       TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions Threaded
View previous topic :: View next topic  
Author Message
Robert Wagner Campos



Joined: 07 Oct 2008
Posts: 16
Location: Brasil

PostPosted: Wed Feb 22, 2012 7:40 pm    Post subject: IDE help Reply to topic Reply with quote

I just installed Visual C++ 2008 Express Edition. I dont know where i configure it to properly compile multiple source files project. It do well just when the project is a single file.

eg. Source_B.c has a reference to a global variable declared in Source_A.c

When Source_B.c is compiled i have this: error C2065: 'varname' : undeclared identifier

The same sources compiled in Visual Studio 2005 years ago, so its a IDE misconfiguration right?

The sources remains intact.

Any thoughts?


PS: Im not a programmer yet!
Embarassed
Back to top
View user's profile Send private message
Jesús Muñoz



Joined: 13 Jul 2011
Posts: 690
Location: Madrid, Spain.

PostPosted: Wed Feb 22, 2012 8:21 pm    Post subject: Re: IDE help. Reply to topic Reply with quote

Hello Robert:

Robert wrote:
I just installed Visual C++ 2008 Express Edition. I dont know where i configure it to properly compile multiple source files project. It do well just when the project is a single file.

eg. Source_B.c has a reference to a global variable declared in Source_A.c

When Source_B.c is compiled i have this: error C2065: 'varname' : undeclared identifier

The same sources compiled in Visual Studio 2005 years ago, so its a IDE misconfiguration right?

The sources remains intact.

Any thoughts?


PS: Im not a programmer yet!
Embarassed


I am not a programmer. I have searched 'error c2065 microsoft vs 2008' in Google. I copy some URLs:

[url]http://msdn.microsoft.com/en-us/library/ewcf0002(v=vs.80).aspx[/url]

[url]http://msdn.microsoft.com/en-us/library/ms177253(v=vs.80).aspx[/url]

The first link explains a little the error C2065, which is in fact:

Quote:
'identifier' : undeclared identifier


The second link explains some things about the changes in Visual C++ 2005 Compiler. Quoting a little:

Quote:
Enforce parameter checking for Visual C++ attributes
Code that passes named attributes to the attribute constructor in quotes when the type is not a string and without quotes when the type is a string will now give Compiler Error C2065 or Compiler Warning (level 1) C4581. Previously all compiler attributes were parsed as strings, and if needed, the compiler inserted the missing quotes. Attribute support was enhanced by adding parameter checking validation. This will prevent unexpected behavior due to incorrect arguments to an attribute constructor.

For this release you cannot have a multi-byte character string (MBCS) in any argument to an attribute which takes an implicit string as an argument, even if the string is quoted (doing so can result in a corrupt .idl file). The workaround is as follows:

Code:
#define ARG string_with_MBCS_chars
[helpstring(ARG)]


But maybe the most useful link for you is the next one:

http://resnikb.wordpress.com/2009/10/28/using-visual-studio-2008-with-visual-c-6-0-compiler/

In post #3, there is someone with the same problem as you, and got answered:

Bojan Resnik wrote:
umesh wrote:
3.umesh said
December 29, 2009 at 12:07
I have created one application in VS2005. It is working perfectly. But when i am building same application in VS 2008 it is showing these errors please help.

C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(771) : error C2065: ‘T’ : undeclared identifier
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(818) : error C2061: syntax error : identifier ‘T’
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(774) : error C2065: ‘T’ : undeclared identifier
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(820) : error C2065: ‘ppT’ : undeclared identifier
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(821) : error C2065: ‘ppT’ : undeclared identifier
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(823) : error C2065: ‘ppT’ : undeclared identifier
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(839) : error C2065: ‘T’ : undeclared identifier
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(847) : error C2065: ‘T’ : undeclared identifier

Reply


Bojan Resnik said
December 29, 2009 at 13:25
Do you mean that the application is compiled with Visual Studio 6.0 under VS 2005 or that it is a regular VS 2005 application?

If the former, then most probably you did not run the vcvars32.bat file that came with Visual Studio 6.0 or you did not supply the /useenv switch when starting VS 2008.

Reply


I hope it will be useful. I wish you good luck because it is all the help I can give you. And please do not underestimate Google!

Regards from Spain.

Ajedrecista.
_________________
Six Fortran 95 tools.

Chess will never be solved.
Back to top
View user's profile Send private message Visit poster's website
Robert Wagner Campos



Joined: 07 Oct 2008
Posts: 16
Location: Brasil

PostPosted: Thu Feb 23, 2012 1:47 am    Post subject: Re: IDE help. Reply to topic Reply with quote

Thanks Jesús

But all i tried has fail.

I managed to remove the problem after uninstalling all VS 2008!

I will try another compiler but it must run on Windows 7, generate x86 and x64 executables, accept x64 intrinsics, and will be welcome if its free.

Can someone recommend something?
Back to top
View user's profile Send private message
jose mº velasco



Joined: 21 Feb 2011
Posts: 479

PostPosted: Thu Feb 23, 2012 2:19 am    Post subject: Re: IDE help. Reply to topic Reply with quote

Microsoft Visual Studio 11 Developer Preview

http://msdn.microsoft.com/en-us/vstudio/hh127353

and now

Dev C++ whit MinGW64 bits compile.

http://orwellengine.blogspot.com/

Cherss.
Back to top
View user's profile Send private message
E Diaz



Joined: 12 Jul 2011
Posts: 182

PostPosted: Thu Feb 23, 2012 9:40 am    Post subject: Re: IDE help. Reply to topic Reply with quote

Maybe you can try these:

http://www.codeblocks.org/

http://www.codelite.org/

Cheers

E Diaz
_________________
Two first meanings of the dutch word "leren":
1. leren [vc] (learn, larn, acquire) acquire or gain knowledge or skills.
2. leren [v] (teach, learn, instruct) impart skills or knowledge to.
Back to top
View user's profile Send private message Visit poster's website
Lucas Braesch



Joined: 31 May 2010
Posts: 1734

PostPosted: Thu Feb 23, 2012 9:59 am    Post subject: Re: IDE help Reply to topic Reply with quote

Robert wrote:
I just installed Visual C++ 2008 Express Edition. I dont know where i configure it to properly compile multiple source files project. It do well just when the project is a single file.

eg. Source_B.c has a reference to a global variable declared in Source_A.c

When Source_B.c is compiled i have this: error C2065: 'varname' : undeclared identifier

The same sources compiled in Visual Studio 2005 years ago, so its a IDE misconfiguration right?

The sources remains intact.

Any thoughts?


PS: Im not a programmer yet!
Embarassed

as much as i love criticizing microsoft, your problem has more to do with your misunderstanding of the C language than the microsoft IDE. in particular compiling units arecompiled independantly and linked at the end. so a variabled defined in source_b.c cannot be used in source_a.c unless you use extern to declare it in source_a.c
Back to top
View user's profile Send private message
H.G.Muller



Joined: 10 Mar 2006
Posts: 12760
Location: Amsterdam

PostPosted: Thu Feb 23, 2012 3:19 pm    Post subject: Re: IDE help Reply to topic Reply with quote

The proper way to handle global variables shared by several .c files is to create a 'header file' xxx.h, in which you declare

Code:
extern int varname;


and then put at the top of every .c file using varname

Code:
#include "xxx.h"


This 'declares' the variable varname, i.e. tells the compiler that it is an int, so that you won't run into error C2065 anymore in any of these files.

In one of the files you would still have to actually reserve memory space for it (make it 'internal', as it were, rather than leaving the compiler under the impression it is external), by writing

Code:
int varname;


in there. Otherwise you would get an 'undefined reference to _varname' error from the linker.
Back to top
View user's profile Send private message Visit poster's website
Robert Wagner Campos



Joined: 07 Oct 2008
Posts: 16
Location: Brasil

PostPosted: Fri Feb 24, 2012 10:50 pm    Post subject: Re: IDE help Reply to topic Reply with quote

Thanks H.G.Muller

What i do was:

-Correct declaration of the var as extern in SourceA
-Correct inicialization and use of the var in SourceA
-put #include of SourceB in SourceA file?
-omitting #include of SouceA in sourceB??

duh

Now the use of the .h suggested seems to be good.


I have learned Basic 20 years ago, Pascal 10 years ago and start something with C in a spare time in 2008 (the code comes from a backup from that time).

I have no idea how to some C things work at all till now.

My error was trust in the backup code (because i have a vague memory with it worked in past) and dont trust in the compiler.

The road till a perft function in C of yesterday became a kind of interstellar travel now!


But i still dream...
Back to top
View user's profile Send private message
Kevin Hearn



Joined: 30 Dec 2010
Posts: 103

PostPosted: Fri Feb 24, 2012 11:13 pm    Post subject: Re: IDE help Reply to topic Reply with quote

Kinda surprised it compiled in an earlier version to begin with.

at any rate, most .c files tends to have a .h file, the .h file tends to include:

type definitions
prototypes of functions i.e. void somefunc(int a);
extern declarations of global variables that are used in other .c files
constants/enums

this is the stuff other compilation units need to know to get things ready for the linker.
each .c file will then include the .h's of any other compilation unit that it needs to access parts of.


you place these in a .h file so that they only have to exist in one place and because other .c files need to know about them. If you only have two .c files you might just put the extern into that .c file but by the time you have a whole mess of .c files it's far more convenient to be able to just include the collection of .h files you need in each .c than to try to remember all the different externs and function prototypes you call from each individual file.

so in this case

sourceA.c:
Code:

#include "sourceA.h"
int myGlobalInt;
...


sourceA.h:
Code:

extern int myGlobalInt;
...


sourceB.c:
Code:

#include "sourceA.h"
...


You can of course instead just create one master .c file that includes all other files turning the project into a single compilation unit.
Back to top
View user's profile Send private message
Robert Wagner Campos



Joined: 07 Oct 2008
Posts: 16
Location: Brasil

PostPosted: Sat Feb 25, 2012 12:08 am    Post subject: Re: IDE help Reply to topic Reply with quote

Thanks Kevin

Now i really understands the use of .h and #include stuff to the code be accepted to the compiler.

Last question: I am just curious if there are any advantage(speed or size) of use multi sources instead of one big C.

I expect a big no answer. Wink

This is just a question of organization, right?

To moderators: Feel free to move this thread to General Topics if there are to much programmers bored with this discussion. Embarassed
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic       TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions All times are GMT
Goto page 1, 2  Next
Threaded
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
Enhanced with Moby Threads