This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Precompiled Header

Note: This was originally posted on 8th June 2010 at http://forums.arm.com

Problem:
I've been trying to utilize precompiled header option, but with no luck. Even after installing patch 771 for RVCT 4.0.

Here what I'm trying to do.
Assume I have 3 source files and 1 header:

0. /myproject/inc/aaa.h
-----------------------------------
// a bunch of definitions


1. /myproject/src/AAA.c  (created this file to include only the header file and compiled with --create_pch=AAA.pch)
------------------------------
#include "aaa.h"  // this is a very large file
//eof

2. /myproject/src/File1.c (compiled with --use_pch=AAA.pch)
---------------------------------
#include "aaa.h"

// some codes


3. /myproject/differentsrc/File2.c (compiled with --use_pch==AAA.pch)
---------------------------------
#include "aaa.h"

// some codes


So the problem:
File1.c is using AAA.pch and compiled in a snap without any problem.

But File2.c can't use AAA.pch and does a regular compile (long compile). It gives warning:
"no source": Warning:  #629-D: the command line options do not match those used when precompiled header file "AAA.pch" was created

Questions:
- Is this a limitation for the precompiled header option? Files must be in the same directory.
- Are there any other options on how to solve this?

Thank you,
-a
  • Note: This was originally posted on 19th June 2010 at http://forums.arm.com

    It's possible that AAA.pch does actually depend on the current directory or current source file directory.  Does aaa.h contain any #includes?

    Can you show the full command lines for the different compile steps?  Are there any differences besides the pch options and filenames?


    No, aaa.h contains only definitions

    So here again:
    The Files:
         /myproject/inc/aaa.h
         /myproject/src/AAA.c    (only contain 1 line: #include "aaa.h")
         /myproject/src/File1.c   (#include "aaa.h")
         /myproject/differentsrc/File2.c  (#include "aaa.h")

    /project/build/makefile
    armcc -c $(SOMEFLAGS) -I../inc -I../src -I../differentsrc --create_pch=../obj/AAA.pch ../src/AAA.c -o --/obj/AAA.o
    armcc -c $(SOMEFLAGS) -I../inc -I../src -I../differentsrc --use_pch=../obj/AAA.pch ../src/File1.c -o --/obj/File1.o
    armcc -c $(SOMEFLAGS) -I../inc -I../src -I../differentsrc --use_pch=../obj/AAA.pch ../differentsrc/File2.c -o --/obj/File2.o

    Only File1.c is compiled and use pch file.
    File2.c is compiled and but not using pch file. It gives me warnings:
    "no source": Warning:  #629-D: the command line options do not match those used when precompiled header file "../obj/AAA.pch" was created

    Even though, as you see above, the command line options match.


    Thank you,
    -Andreas
  • Note: This was originally posted on 23rd June 2010 at http://forums.arm.com

    Thanks algrant,

    The switch (--sys_include) does the job. Now files can use the pch file.
    Though, I have to make sure the order of #include match with the one used for creating the pch file.
    For my example above,

    #include "aaa.h" must be declared first on the top of c files.
  • Note: This was originally posted on 21st June 2010 at http://forums.arm.com

    The compiler by default will put the "current place" (the place where the current file is) as the first item on the include path.
    This means the #include "aaa.h" will look first in the same directory as the source, so the PCH is sensitive to the location
    of that directory (even though the include file wasn't actually found there).

    You can use --sys_include to stop putting the "current place" on the include path.  That should make this build reuse PCH.
  • Note: This was originally posted on 1st December 2010 at http://forums.arm.com

    Hi, I have a similar problem, but with a twist. --sys_include or --kandr_include makes the warning go away, but both of these options break relative includes in .h files.




    For instance:

    In the file test.cpp, which resides in directory "some_dir", I have #include "some_other_dir/some_inc.h"

    In "some_inc.h", I have #include "some_other_inc.h", where "some_other_inc.h" resides in directory "some_other_dir" and is no longer found.

    We have a pretty big bunch of code which relies on this sort of relative includes and it would be great if we could still leverage the advantages of PCH.

    What can we do?







  • Note: This was originally posted on 14th June 2010 at http://forums.arm.com

    [...]
    But File2.c can't use AAA.pch and does a regular compile (long compile). It gives warning:
    "no source": Warning:  #629-D: the command line options do not match those used when precompiled header file "AAA.pch" was created

    Questions:
    - Is this a limitation for the precompiled header option? Files must be in the same directory.
    - Are there any other options on how to solve this?


    It's possible that AAA.pch does actually depend on the current directory or current source file directory.  Does aaa.h contain any #includes?

    Can you show the full command lines for the different compile steps?  Are there any differences besides the pch options and filenames?