Thread: C++ linkage errors

  1. #1
    Registered User
    Join Date
    Oct 2005

    C++ linkage errors

    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,
    /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" {
    #include <syslog.h>
    #include <stdarg.h>
    #ifdef __cplusplus
    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 ?
    Last edited by Salem; 01-13-2010 at 10:38 AM. Reason: tags placement

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    It looks to me like you have multiple places where you include syslog.h.

    But in some of them, you don't have the __cplusplus guard, so it starts off being prototyped as a C++ function (and then later as a C function, and then the error messages).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linkage question
    By DL1 in forum C++ Programming
    Replies: 6
    Last Post: 01-13-2009, 07:56 PM
  2. internal/external linkage
    By MarkZWEERS in forum C++ Programming
    Replies: 1
    Last Post: 07-29-2008, 03:34 AM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM