Re: Question about Leverage source from Different Projects



<slapping self> Even if it would have compiled, by suggestion wouldn't work, since I didn't take
into account the relative path of stdafx.h.
I've done similar things in the past with conditionally including headers depending on the project,
and I just carelessly assumed I knew what I was talking about here.

However, I guess one could create a stdafx.h in the directory with the shared .cpp and put all that
conditional preprocessor stuff INSIDE the stdafx.h depending on the project macro defined.

"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:gpmis2lvv46cedu33rqlib5cmmhnlqp836@xxxxxxxxxx
That actually won't work. For example, everything up to
#include "stdafx.h"
is treated as a syntactically ill-formed comment. So the #if is not seen, nor is the
#pragma, but the #elif will be seen and complain that it is unmatched.

I've done this a lot of times and never had a problem with the use of stdafx.h in the
files I'm including from another project. I'm not even sure I understand why the issue
arises.

There is, as far as I can tell, not even a discussion of the .cpp files, just a strange
comment that there is a problem, but nothing prior to this suggests that there should be a
problem.

I have many projects which have shared source and shared include directories, and I just
include the source files from the source directories and the header files from the include
directory and it all works.
joe

On Tue, 6 Feb 2007 22:23:34 -0600, "Scot T Brennecke" <ScotB@xxxxxxxxxxxxxxxxxx> wrote:

If you have one project that uses the precompiled headers and another one that doesn't, you can
use
preprocessor directives to determine whether or not to #include "StdAfx.H" in the .cpp For
instance:

#if defined(__MFCPROJECT__)
#pragma message("Building MfcProject")
#include "StdAfx.H"
#elif defined(__LEVERAGEDMFCPROJECT__)
#pragma message("Building LeveragedMfcProject")
#endif

To make this work, just add those macros to your project preprocessor defines.


.



Relevant Pages

  • Re: Conditional compilation sans the cpp
    ... a design for some kind of macro firewall that is supposed to isolate code ... from an effects from the preprocessor. ... I fully understand that the CPP has been used to to some great stuff. ... "There is only One inviolable Law" ...
    (comp.lang.cpp)
  • Re: Cpp Considered Harmful
    ... not bring down the server. ... > library management when finally addressing the preprocessor in the ... regarding the CPP. ...
    (comp.lang.cpp)
  • Re: delete comments in .c file
    ... Assuming you have access to the C preprocessor (cpp) you can do a quick hack ... Isolate the file from it's include files and run like, ...
    (comp.lang.c)
  • Re: To bean or not to bean
    ... Qt development begain in 1991, and the first public release was on the 20th ... The preprocessor is the main reason that there is no serious C++ contender ... techniques it supports do not scale to that level of programming. ... and the Cpp than he does. ...
    (comp.lang.cpp)
  • change a #include directory
    ... I trying to get the preprocessor to include a file from a directory based on ... I want to be able to switch between internal ... #ifdef USE_TRUNK ... (I also want to use a #pragma comment lib to link ...
    (microsoft.public.vc.language)