Losing preprocessor defintion after generating first temporary file

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Sachin Sharma (sachinssharma_at_hotmail.com)
Date: 11/20/04

  • Next message: Sachin Sharma: "Re: Losing preprocessor defintion after generating first temporary file"
    Date: Sat, 20 Nov 2004 18:30:02 +0530
    
    

    Hello,

    I have a regular DLL using Win32 APIs that I compile with Visual C++.NET
    2003. In one of the files, say "d.cpp", I have this code:

    #if defined(PRE_ID)
    char* pszID = "12345";
    #else
    char* pszID = NULL;
    #endif

    Now, I have two release configurations. Same in all other settings, except
    that the new configuration contains PRE_ID in Project > Properties > C/C++ >
    Preprocessor > Preprocessor Definitions. When I compile the new
    configuration, I get char* pszID = NULL and not the other declaration as
    expected.

    The build log shows that first the compiler creates a temporary files then
    compiles a few files, then another temporary file and compiles only
    stdafx.cpp. Finally a third temporary file where it compiles our "d.cpp".
    The first temporary file shows /D "PRE_ID" as part of the command line but
    the second and the third does not.

    To confirm this, if I put the above mentioned code in the first file that
    compiles as part of the first temporary file then everything works as
    expected. So I have a workaround. But why this behavior?

    In addition, it is interesting to note that the order of compilation is in
    descending order of file names (Z to A) - in this case at least.

    Please help.

    Regards,
    Sachin Sharma


  • Next message: Sachin Sharma: "Re: Losing preprocessor defintion after generating first temporary file"

    Relevant Pages

    • Re: Losing preprocessor defintion after generating first temporary file
      ... > Preprocessor> Preprocessor Definitions. ... > compiles a few files, then another temporary file and compiles only ... > compiles as part of the first temporary file then everything works as ... first temporary file inherited their properties from the project. ...
      (microsoft.public.vc.ide_general)
    • Linker problem with DirectShow
      ... The project compiles fine, but when ... other libs; use /NODEFAULTLIB:library ... Creating temporary file ... Creating command line "cl.exe ...
      (microsoft.public.win32.programmer.directx.video)
    • Linker problem with DirectShow
      ... The project compiles fine, but when ... other libs; use /NODEFAULTLIB:library ... Creating temporary file ... Creating command line "cl.exe ...
      (microsoft.public.multimedia.directx.dshow.programming)
    • Re: Linker problem with DirectShow
      ... The project compiles fine, but when ... other libs; use /NODEFAULTLIB:library ... Creating temporary file ... Creating command line "cl.exe ...
      (microsoft.public.win32.programmer.directx.video)