Ask a questionAsk a question
 

Answerextern nesting issue

  • Thursday, November 05, 2009 10:45 PMrepressed Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    My team has a large solution (think a million+ of lines of C/C++ code) that we are porting from a non-MS environment to CE.  Since a lot of the header files are used by a mix of C and C++ most tend to have the classic

    #ifdef __cplusplus
    extern "C" {
    #endif
    ...
    #ifdef __cplusplus } #endif
    wrapping their entire contents.  The problem is that it appears that the microsoft compiler preprocessor doesn't handle extern nesting beyond a level of 10.  (See http://msdn.microsoft.com/en-us/library/ft39hh4x(VS.71).aspx.)  I'm not sure how many levels deep we need to go but it is clearly beyond this limit. 

    Short of touching a lot (and I do mean a lot) of header files, is there any way around this limit?  It looks like this is a hard coded limit in the tool but does anyone know if is there a registry key or preprocessor command that will override it?  Or does anyone know of a solution that won't involve touching a very large number of header files?

    (It also begs the question of why what is supposed to be a world class tool falls so far short of the recommended value of 1024 that the C++ standard specifies?)

Answers

  • Friday, November 06, 2009 1:36 AMrepressed Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    BTW, there *is* a work around that involves touching the header files.   The answer lies in use of #pragma push_macro and #pragma pop_macro to keep the state of whether the close bracket should be used and you only use the first extern "C" and corresponding close bracket.

    I'm just hoping to find an answer that doesn't involve writing a perl script to touch *a lot* of header files.

  • Tuesday, November 24, 2009 8:05 AMRong-Chun ZhangMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hello,

    After discussing with product team, fixing the header files seems to be the only workaround.

    Thanks,
    Rong-Chun Zhang
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

All Replies

  • Friday, November 06, 2009 1:36 AMrepressed Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    BTW, there *is* a work around that involves touching the header files.   The answer lies in use of #pragma push_macro and #pragma pop_macro to keep the state of whether the close bracket should be used and you only use the first extern "C" and corresponding close bracket.

    I'm just hoping to find an answer that doesn't involve writing a perl script to touch *a lot* of header files.

  • Friday, November 06, 2009 12:44 PMRong-Chun ZhangMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello

    Thanks for you post.

    >It looks like this is a hard coded limit in the tool but does anyone know if is there a registry key or preprocessor command that will override it?

    I don't think this can be override by the registry key as this is Compiler Limit. I will discuss with product team to see if this is an work around, I will get back to up as soon as possible.

    Thanks,
    Rong-Chun Zhang
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Tuesday, November 24, 2009 8:05 AMRong-Chun ZhangMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hello,

    After discussing with product team, fixing the header files seems to be the only workaround.

    Thanks,
    Rong-Chun Zhang
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.