Keil™, An ARM® Company

Discussion Forum

Precompiled header files

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Author
Jan Raddatz
Posted
25-Nov-2009 16:14 GMT
Toolset
ARM
New! Precompiled header files

Hello forum,
I want to take use of precompiled header files in my project. My project is split into two parts. A library part and an application part.

The application part is using the library part by including a single header file called library.hpp. library.hpp contains a ton of includes.

I want to create a pch file out of library.hpp and force the ARM compiler to use that instead of recompiling each header file over and over again.
My problem is that I don't get uVision3 configured in a way that this pch file is properly created.

Here is what I did so far:
- create a cpp file called library.cpp
- configured the library.cpp C/C++ options with --create_pch=library.pch
- configured the overall project C/C++ options with --use_pch=library.pch

When I compile the project the library.pch is created but for each cpp file that is processed the compiler outputs a warning that the pch file has been created with compiler options different from current options.

Please can you give me a hint what I am doing wrong or direct me to any tutorials, sample projects?
I am using Cortex-M3 on ARM-MDK4.0 with uVision 3.9
Thanks a lot in advance and best regards
Jan

Author
ccPer Westermark
Posted
25-Nov-2009 23:35 GMT
Toolset
ARM
New! RE: Precompiled header files

Turn on listing files, so you get *.txt files in the output directory. At the top of each *.txt file, you will see a list of compiler options used for compiling that source file.

Is there any difference between compiling the source files in the library and the source files using the library?

Author
Tamir Michael
Posted
26-Nov-2009 07:34 GMT
Toolset
ARM
New! RE: Precompiled header files

Per,
Your forum name is prepended by 2 'c' characters :-)

Author
Per Westermark
Posted
26-Nov-2009 10:06 GMT
Toolset
ARM
New! RE: Precompiled header files

A common problem with this forum. The web form has the "First Name" field selected when you try to reply. Then you'll have to wait for a later post to try to remember to fix it.

Author
Jan Raddatz
Posted
26-Nov-2009 08:16 GMT
Toolset
ARM
New! RE: Precompiled header files

@cc: Thanks for your quick response I will try that as soon as I am back in the office today!

Author
Jan Raddatz
Posted
27-Nov-2009 20:58 GMT
Toolset
ARM
New! RE: Precompiled header files

Hi Per,
I tried to get a clue out of the list files but can't say there are differences.

Actually I think that I do something wrong when creating the pch file.

How would you configure a project for using pch files?

Thanks a lot in advance and best regards.
Jan

Author
Jan Raddatz
Posted
27-Nov-2009 21:40 GMT
Toolset
ARM
New! RE: Precompiled header files

Hi again,
here's a short update of what I did so far:

I have three files:
main.cpp
stdafx.cpp
stdafx.hpp

In C/C++ options I added a "Misc Control" to main.cpp: --use_pch=stdafx.pch

In C/C++ options I added a "Misc Control" to stdafx.cpp:
--create_pch=stdafx.pch

my main.cpp looks like this:

#include "stdafx.hpp"
int main(void)
{ }

my stdafx.cpp looks like this:
#include "stdafx.hpp"

my stdafx.hpp looks like this:
#include "..."
#include "..."
// ... tons of includes

When I build my mini project I am getting the following warning:
main.cpp: Warning: #629-D: the command line options do not match those used when precompiled header file "stdafx.pch" was created

I really don't know how to get this pch thing working with Keil!

Please can anyone help me and direct me how to set these things up correctly?
Thanks a lot in advance!
Jan

Next Thread | Thread List | Previous Thread Start a Thread | Settings