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!
IDE help
Moderators: hgm, Rebel, chrisw
-
- Posts: 1968
- Joined: Wed Jul 13, 2011 9:04 pm
- Location: Madrid, Spain.
Re: IDE help.
Hello Robert:
http://msdn.microsoft.com/en-us/library ... s.80).aspx
http://msdn.microsoft.com/en-us/library ... s.80).aspx
The first link explains a little the error C2065, which is in fact:
http://resnikb.wordpress.com/2009/10/28 ... -compiler/
In post #3, there is someone with the same problem as you, and got answered:
Regards from Spain.
Ajedrecista.
I am not a programmer. I have searched 'error c2065 microsoft vs 2008' in Google. I copy some URLs: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!
http://msdn.microsoft.com/en-us/library ... s.80).aspx
http://msdn.microsoft.com/en-us/library ... s.80).aspx
The first link explains a little the error C2065, which is in fact:
The second link explains some things about the changes in Visual C++ 2005 Compiler. Quoting a little:'identifier' : undeclared identifier
But maybe the most useful link for you is the next one: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: Select all
#define ARG string_with_MBCS_chars [helpstring(ARG)]
http://resnikb.wordpress.com/2009/10/28 ... -compiler/
In post #3, there is someone with the same problem as you, and got answered:
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!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
Regards from Spain.
Ajedrecista.
-
- Posts: 20
- Joined: Tue Oct 07, 2008 2:53 am
- Location: Brasil
Re: IDE help.
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?
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?
-
- Posts: 1600
- Joined: Mon Feb 21, 2011 9:48 am
Re: IDE help.
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.
http://msdn.microsoft.com/en-us/vstudio/hh127353
and now
Dev C++ whit MinGW64 bits compile.
http://orwellengine.blogspot.com/
Cherss.
-
- Posts: 238
- Joined: Tue Jul 12, 2011 1:31 pm
Re: IDE help.
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.
1. leren [vc] (learn, larn, acquire) acquire or gain knowledge or skills.
2. leren [v] (teach, learn, instruct) impart skills or knowledge to.
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: IDE help
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.cRobert 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!
-
- Posts: 27793
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: IDE help
The proper way to handle global variables shared by several .c files is to create a 'header file' xxx.h, in which you declare
and then put at the top of every .c file using varname
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
in there. Otherwise you would get an 'undefined reference to _varname' error from the linker.
Code: Select all
extern int varname;
Code: Select all
#include "xxx.h"
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: Select all
int varname;
-
- Posts: 20
- Joined: Tue Oct 07, 2008 2:53 am
- Location: Brasil
Re: IDE help
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...
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...
-
- Posts: 411
- Joined: Thu Dec 30, 2010 4:48 am
Re: IDE help
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:
sourceA.h:
sourceB.c:
You can of course instead just create one master .c file that includes all other files turning the project into a single compilation unit.
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: Select all
#include "sourceA.h"
int myGlobalInt;
...
Code: Select all
extern int myGlobalInt;
...
Code: Select all
#include "sourceA.h"
...
-
- Posts: 20
- Joined: Tue Oct 07, 2008 2:53 am
- Location: Brasil
Re: IDE help
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.
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.
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.
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.