Archived

This forum has been archived. Please start a new discussion on GitHub.

Pre-Compiled Headers

Hello,

Ice 2.1.1
Visual C++ .NET 2003 (7.1)

I'm in the process of configure my project to use Pre-Compiled Headers to improve build speed.

I have a problem with the compiled generated files with slice2cpp because it doesn't include the precompiled header file (i.e: #include "precompiled.h") and the C++ compiler raises an error.
I haven't see any command line option in slice2cpp to include a precompiled header file.

What's your advice to this problem? Sure I can include this file with a script after compiling the slice file but, are there other solution?

Thank you all for your time and help!

Mario

Comments

  • I'll have a look at this to see how much difference precompiled headers make and, if that makes a worthwhile difference, how to permit this in the build system.

    Cheers,

    Michi.
  • mario wrote:
    I have a problem with the compiled generated files with slice2cpp because it doesn't include the precompiled header file (i.e: #include "precompiled.h") and the C++ compiler raises an error.

    I assume that you want to use precompiled headers manually? If so, could you explain why? I tried using the /YX option, which causes the compiler to use precompiled headers automatically. With that, no source code changes are necessary, and build times improve somewhat.
    I haven't see any command line option in slice2cpp to include a precompiled header file.

    No, there is no such option. We could add one, but I'd have to be convinced of its usefulness first.
    What's your advice to this problem? Sure I can include this file with a script after compiling the slice file but, are there other solution?

    Why not just enable automatic precompiled headers? That way, you don't have to change anything in the code.

    (As an aside, I believe that any approach that requires source code changes in order to use precompiled headers is fundamentally broken -- it should be the compiler's job to figure out what needs recompiling, not the programmer's.)

    Cheers,

    Michi.
  • Thanks for your reply, Michi.
    michi wrote:
    I assume that you want to use precompiled headers manually? If so, could you explain why? I tried using the /YX option, which causes the compiler to use precompiled headers automatically. With that, no source code changes are necessary, and build times improve somewhat.
    The "automatic precompiled headers" option in MSVC is very inefficient, not only the improvement are very low but, unless you are exquisitely careful, this "automatic" use of precompiled headers translates to "rebuilding the precompiled headers for every source file."

    You can read about this at Bruce Dawson's paper. Also in Games from Within by Noel Llopis there're some articles about this subject.

    For example, in one of my projects my rebuild times went from roughly 40 secs. to 11 secs! :):)
    michi wrote:
    (As an aside, I believe that any approach that requires source code changes in order to use precompiled headers is fundamentally broken -- it should be the compiler's job to figure out what needs recompiling, not the programmer's.)
    Yes, I agree absolutelly with this but, almost in MSVC, there isn't another solution for this... :(

    Thanks,

    Mario
  • Yes, I found it's inconvenient to cooperate Create Precompiled Header (/Yc) options with ICE.
  • Hi yomi, I think pre-compiled headers are a very valuable help to accelerate compile times for C++ projects, and not only in full rebuild but in incremental builds (much more important in daily work).

    You can make use of two strategies:
    • Deactivate pre-compiled headers for the generated cpp from slice files. This isn't actually a problem because that generated cpp files have a very good structure and build times are very good without pre-compiled headers. You can still make use of pre-compile headers for the rest of your project.
    • Write a script that automatically compile (slice2cpp) the slice files and, for each file, add at the begining of the file, the include line (#include "precompiled.h"). Python is great for that.

    Regards

    Mario
  • yomi wrote:
    Yes, I found it's inconvenient to cooperate Create Precompiled Header (/Yc) options with ICE.

    I'm not sure you want to generate PCHs automatically for project files... If I read your post right, and you only want to avoid the C1010 compilation error, can't you simply specify Not Using Precompiled Headers under the compilation unit properties?

    HTH

    This being my first post, I also wanted to say "well done" to ZeroC. Forgive the gushing, but Ice is some very cool middleware: great feature set and language coverage, brilliant documentation, and with an API that makes me feel like I should be working harder (as opposed to CORBA, which only taught me some new profanities). Looking forward to Ice-Grid...
  • yomi wrote:
    Yes, I found it's inconvenient to cooperate Create Precompiled Header (/Yc) options with ICE.

    The next version of Ice will allow you inject the appropriate #include directives into the generated code, so you can use precompiled headers if you wish.

    Cheers,

    Michi.
  • Hello,
    In fact, I use maybe a better and simpler way to solve this problem.
    I write a cpp file, which include the to precompile header file and the cpp ice generated. It looks like this:

    #include "precompile.h"

    #include "ice_gen1.cpp"
    #include "ice_gen2.cpp"

    It works very well. I don't need to do any extra thing.

    Regards,
    Yomi
  • michi wrote:
    The next version of Ice will allow you inject the appropriate #include directives into the generated code, so you can use precompiled headers if you wish.
    Michi.
    Good news, thanks :)
    yomi wrote:
    I write a cpp file, which include the to precompile header file and the cpp ice generated.
    The problem with this approach is that if one cpp file is modified, all the rest will be compiled too. This conflicts with using pre-compiled headers to accelerate compile times for incremental builds.

    Regards,

    Mario