Menu

Remove #ifdef __cplusplus ?

2016-02-08
2016-02-09
  • Edward Hague

    Edward Hague - 2016-02-08

    Steve

    May I suggest removal of all

    #ifdef __cplusplus
    extern "C" { 
    #endif
    

    from the stack?

    I often compile the stack in C++ (g++ in linux or /TP in MSVC) for better type-checking, in which case the #ifdef limits the scope of this.

    (Typically I search&replace cplusplus with cplusplus_something_else to disable the protection.)

    cplusplus is useful for libraries where the library source is unavailable. All projects using your stack have all the source available, so there is no need for this...

    Anyone else wish to comment?

    Ed

    bitsissue00001

     

    Last edit: Edward Hague 2016-02-08
  • Steve Karg

    Steve Karg - 2016-02-09

    The extern "C" is used to prevent name mangling when using the library as a C library along with C++ code. I use this technique when mixing with C++ - even when I have source - or the C files cannot link to the C functions in other C files.

    Perhaps adding another define would suffice for your project?

    #if defined(__cplusplus) && !defined(BACNET_CPP)
    extern "C" { 
    #endif
    
     

Log in to post a comment.