-
February 9th, 2004, 04:20 AM
#1
multiple declaration error
I have three files say
common_defs.h
main.c
#includes common_defs.h as well as common_defs.h
contains the main function
abc.c
#includes common_defs.h
i compile main.c and abs.c separately to creeate
the respective .o files
Now for the final compilation, my compiler (icc) gives multiple declaration error for all the constants defined in common_defs.h
Any solution,
-
February 9th, 2004, 04:25 AM
#2
Did you add inclusion guards to your header files...
Code:
#ifndef __CLASS_A_HPP
#define __CLASS_A_HPP
// Your class declaration
#endif
-
February 9th, 2004, 04:35 AM
#3
Yes I did
One more finding
I am using C. Also using constants are allowed as per the new C standard
The other thing i just found
is that if i use #defines instead of const int things work just fine
Is there any diff between the C and C++ constants that is causing problems.
I have also used extern "c"
Thanks
-
February 9th, 2004, 04:58 AM
#4
Well...you might want to take a look at the following FAQ...
-
February 9th, 2004, 05:23 AM
#5
Are you suggesting to use something like
extern const int x ?
To be very precise my problem is because I compile in stages
first main.o is created
then abc.o is created
both have space allocated for the common_defs
Now when i compile the object files together there is a multiple declaration error ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|