Re: Losing preprocessor defintion after generating first temporary file

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


Date: Sat, 20 Nov 2004 19:33:42 +0530


"Sachin Sharma" <sachinssharma@hotmail.com> wrote in message
news:eWr6vAwzEHA.3028@TK2MSFTNGP10.phx.gbl...
> 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
>

Hello,

Ok, I found out what was wrong. The files being compiled as part of the
first temporary file inherited their properties from the project. This was
not the case for files being compiled as part of the third temporary file.
After I set this property for all files in the solution, life is great.

Regards,
Sachin Sharma



Relevant Pages

  • Losing preprocessor defintion after generating first temporary file
    ... char* pszID = NULL; ... compiles a few files, then another temporary file and compiles only ... Finally a third temporary file where it compiles our "d.cpp". ... compiles as part of the first temporary file then everything works as ...
    (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)