C++ linkage error

I am porting a code which ran on HP unix to CentOS. It was a working code and compiled with gcc3.1.x 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

I have the extern "C" included like this . But still I face the same problem . What Am I missing ??

#ifdef __cplusplus
extern "C" {
#endif

#include <syslog.h>
#include <stdarg.h>

#ifdef __cplusplus
}
#endif

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 , Where Am I going wrong ?
Have you identified the source of the previous declaration? Is it defined somewhere in your source tree?
Are you forward declaring and functions not necessarily declared in a header file but implemented in a c library?

Edit:

The linker is saying syslog is previously defined with the c++ then being redefined for c.

I.e. in the example here:
http://www.jbox.dk/sanos/source/include/syslog.h.html

The functional already has the extern symbols.
Last edited on
I once faced a problem that may have something to do with yours, but mine was during the linking process.

Functions using a variable argument list (the ... parameter which is using syslog) may generate undefined symbol errors during the link . GNU libraries define the variable argument list behavior as a set of macros (va_list, va_args, etc), while HP-UX libraries defines it as function calls (function va_list, etc). Be careful to include GNU header files, not HP-UX ones. Pay special attention to the -I parameter in the gcc file.

Returning to your problem and now linking with my previous explanation... have you checked you are using GNU header files?

regards
Victor
I'm not sure if this helps or not, but when mixing C and C++ I always refer back to the two FAQs found here:
http://www2.research.att.com/~bs/bs_faq2.html#callC
Topic archived. No new replies allowed.