C++ linkage errors

This is a discussion on C++ linkage errors within the C++ Programming forums, part of the General Programming Boards category; I am porting a code which ran on HP unix to CentOS. It was a working code and compiled with ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    2

    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.

    Code:
     
    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 ??

    Code:
     
    #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 ?
    Last edited by Salem; 01-13-2010 at 09:38 AM. Reason: tags placement

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,540
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 06: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, 07:13 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21