C++ Learning Community Forum
September 09, 2010, 08:17:06 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Hello.
Home
Help
Search
Login
Register
C++ Learning Community Forum
>
General C++ Programming
>
C++ Help
>
Name Conflicts between C++ and C
Pages: [
1
]
« previous
next »
Print
Author
Topic: Name Conflicts between C++ and C (Read 290 times)
GGF
N00b!!1
Posts: 1
Name Conflicts between C++ and C
«
on:
January 08, 2010, 05:49:24 PM »
I am porting a code which ran on HP unix to CentOS. It was a working code and a c++ file and now I tried to compile with gcc3-3.4.6 and gcc4-4.2.4 also. But still I get this conflicts in declaration error as pasted below.
In file included from ../../../lol/ntk/nt_kslog.h:155,
from ../../../lol/ntk/nt_kernel.h:243,
from ../../../lol/ntk/nt_cp.h:110,
from ../../../soml/include/soml-afi-afu.h:131,
from ../../include/pcdb.h:58,
from ../../include/pcdb_addtypes.h:59,
from pcdb_addtypes.cc:94:
/opt/bcs/include/syslog.h:93: error: previous declaration of 'void syslog(int, const char*, ...)' with 'C++' linkage
/opt/bcs/include/syslog.h:93: error: conflicts with new declaration with 'C' linkage
Here pcdb.h , pcdb_addtypes.h are c++ headers and rest are C headers and I see that proper extern is mentioned in pcdb.h for soml-afi-afu.h. Also syslog is a declaration which I cannot make it extern as I cant change the code. My code is only the C++ part and is the files mentioned above?
Also , I work on Centos 5 box and it compiled without any issues on one machine and the same throws this error on other box with centos and both compilers.
Could anyone please help me as I am in a very hurry to solve this ? Where Am I going wrong ?
Please help.
-GGF
Logged
myork
Global Moderator
C++ guru
Posts: 1147
Re: Name Conflicts between C++ and C
«
Reply #1 on:
January 09, 2010, 09:33:35 PM »
If you are going to use a C++ compiler to compile C source then the C header files should have the following at the top:
Code:
#ifdef __cplusplus
extern "C" {
#endif
// All the normal file stuff
#ifdef __cplusplus
}
#endif
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General C++ Programming
-----------------------------
=> C++ Help
===> C Programming
=> C++ Tips
=> C++ in General
=> 3rd Party Libraries Programming
-----------------------------
Platform Specific Programming
-----------------------------
=> Windows
=> Linux
=> DirectX
=> OpenGL
-----------------------------
C++ Creations
-----------------------------
=> Finished Products
=> Work in Progress
-----------------------------
Resources
-----------------------------
=> Recommended Resources
=> Bookworm's Corner
===> Accelerated C++: Practical Programming by Example
===> Code Complete
-----------------------------
Other than C++....
-----------------------------
=> Off Topic
=> Other Programing Languages
===> ASM Programming
=> Computer Lab
=> The Community
Loading...