Re: Preprocessor, nested files etc.

From: Florian (wizard_oz_at_gmxREMOVEUPPERCASE.net)
Date: 08/13/04


Date: Fri, 13 Aug 2004 14:34:41 GMT

Danke Heinz,

That makes sense now. I just didn't know that in C++ each cpp file is it's
on unit, like Ali said. Thanks a lot for clarifying this, that will make
troubleshooting a bit easier in the future.

Flo

"Karl Heinz Buchegger" <kbuchegg@gascad.at> wrote in message
news:411C76CF.FB80288D@gascad.at...
> Florian wrote:
>>
>> then those macro definitions don't seem to stick. When the next cpp files
>> is
>> being processed, the header file is being included again - even though
>> the
>> macro was previously defined
>>
>> Is this normal, and where am I getting confused?
>
> Each source code file (each *.cpp) is compiled independently of all
> others.
> That's the way things work in C++.
> And of course it makes sense. Your project consists of 10 files. The
> project
> I am involved in, consists of more then 400 files. Consider I make a
> change
> in one of them and the compiler is going to recompile everything
> (sometimes
> we have to do this, it takes around 2 hours for a complete recompile).
>
> When the compiler compiles a *.cpp file, it starts in a fresh state.
> Nothing
> it has learned by compiling a previous source code file remains. Which is
> a good thing, because it means it can compile a collection of *.cpp files
> in any order it likes. If you make a change in one of them, only this file
> needs to be recompiled and the linker will form a new executable from the
> results of all the copilation steps (they are called 'object files' or
> 'machine
> code files')
>
> --
> Karl Heinz Buchegger
> kbuchegg@gascad.at



Relevant Pages

  • Re: Internal Complier Error in Visual C++ 1.52
    ... You're using a very old version of both the IDE and the compiler. ... > function declaration for an existing class in a header file and function ... > implementation in the .cpp file i am getting an error as given below ...
    (microsoft.public.dotnet.languages.vc)
  • Re: LNK2019
    ... the header will include the inline file in a release build and the cpp file ... the compiler and linker to correctly deal with this? ... "exclude from build" which applies to whatever configuration you have selected. ...
    (microsoft.public.vc.mfc)
  • Re: including a large constants file
    ... "john smith" wrote in message ... > If I have a large constants file and include that in a .cpp file will the ... That depends entirely upon your compiler and platform. ... None of what you ask is addressed by the language, ...
    (comp.lang.cpp)
  • Re: Quick question:
    ... Can we pass a pointer to an object from one cpp file to another by ... virtual void SYS_set_SFCC ... Remember that the compiler sees only what you "feed" to it. ... convention of using "header files" - common definitions and declaration are ...
    (microsoft.public.dotnet.languages.vc)
  • Re: How to force a single cpp file to recompile every build?
    ... >cause a recompile and relink. ... I take it that a date in the future on the cpp file will not serve. ... I suggest removing the modelling of the dependency of the executable on ... >because the file is write protected under version control). ...
    (microsoft.public.vc.ide_general)