Precompiled header without prefix header ?

classic Classic list List threaded Threaded
5 messages Options
fab
Reply | Threaded
Open this post in threaded view
|

Precompiled header without prefix header ?

fab
I am working on a cross-platform codebase on Clang/MacOS X that is also compiled with Visual Studio on Windows and GCC on Linux.

The source code headers always include "precomp_common.h" at the top of each header files. But according to the Clang documentation (http://clang.llvm.org/docs/UsersManual.html#usersmanual-precompiled-headers) Clang will NOT use the PCH in this case and no speed up will be performed since it was not include via "- include".

Using Clang it seems the only way is to perform a conditional include:

1.
#ifndef __clang__
   #include "precomp_common.h"
#endif

2. Add "precomp_common.h" to the prefix header via -include option.

I wonder if there is a "cleaner" way to do it.
Reply | Threaded
Open this post in threaded view
|

Re: Precompiled header without prefix header ?

Argyrios Kyrtzidis
On Mar 18, 2013, at 12:44 PM, fab <[hidden email]> wrote:

I am working on a cross-platform codebase on Clang/MacOS X that is also
compiled with Visual Studio on Windows and GCC on Linux.

The source code headers always include "precomp_common.h" at the top of each
header files. But according to the Clang documentation
(http://clang.llvm.org/docs/UsersManual.html#usersmanual-precompiled-headers)
Clang will NOT use the PCH in this case and no speed up will be performed
since it was not include via "- include".

Using Clang it seems the only way is to perform a conditional include:

1.
#ifndef __clang__
  #include "precomp_common.h"
#endif

2. Add "precomp_common.h" to the prefix header via -include option.

You don't need to do 1.; by doing 2. the "#include "precomp_common.h" will just be skipped.


I wonder if there is a "cleaner" way to do it.



--
View this message in context: http://clang-developers.42468.n3.nabble.com/Precompiled-header-without-prefix-header-tp4031029.html
Sent from the Clang Developers mailing list archive at Nabble.com.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Precompiled header without prefix header ?

Sebastian Redl
In reply to this post by fab

On 18.03.2013, at 20:44, fab wrote:

> I am working on a cross-platform codebase on Clang/MacOS X that is also
> compiled with Visual Studio on Windows and GCC on Linux.
>
> The source code headers always include "precomp_common.h" at the top of each
> header files. But according to the Clang documentation
> (http://clang.llvm.org/docs/UsersManual.html#usersmanual-precompiled-headers)
> Clang will NOT use the PCH in this case and no speed up will be performed
> since it was not include via "- include".
>
> Using Clang it seems the only way is to perform a conditional include:
>
> 1.
> #ifndef __clang__
>   #include "precomp_common.h"
> #endif
>
> 2. Add "precomp_common.h" to the prefix header via -include option.
>
> I wonder if there is a "cleaner" way to do it.

I generally find the VS model to be the unclean one. Remove the include directive from all files, and in your project options, under C/C++ -> Advanced, add it to Forced Includes. This makes it pass the file to the compiler via the equivalent of the -include directive. (You still need to have it specified as the precompiled header.)

Sebastian
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
fab
Reply | Threaded
Open this post in threaded view
|

Re: Precompiled header without prefix header ?

fab
In reply to this post by Argyrios Kyrtzidis
So the documentation at (http://clang.llvm.org/docs/UsersManual.html#usersmanual-precompiled-headers) should be disregarded  ?

Fabien

On Mon, Mar 18, 2013 at 9:41 PM, Argyrios Kyrtzidis <[hidden email]> wrote:
On Mar 18, 2013, at 12:44 PM, fab <[hidden email]> wrote:

I am working on a cross-platform codebase on Clang/MacOS X that is also
compiled with Visual Studio on Windows and GCC on Linux.

The source code headers always include "precomp_common.h" at the top of each
header files. But according to the Clang documentation
(http://clang.llvm.org/docs/UsersManual.html#usersmanual-precompiled-headers)
Clang will NOT use the PCH in this case and no speed up will be performed
since it was not include via "- include".

Using Clang it seems the only way is to perform a conditional include:

1.
#ifndef __clang__
  #include "precomp_common.h"
#endif

2. Add "precomp_common.h" to the prefix header via -include option.

You don't need to do 1.; by doing 2. the "#include "precomp_common.h" will just be skipped.


I wonder if there is a "cleaner" way to do it.



--
View this message in context: http://clang-developers.42468.n3.nabble.com/Precompiled-header-without-prefix-header-tp4031029.html
Sent from the Clang Developers mailing list archive at Nabble.com.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Precompiled header without prefix header ?

Argyrios Kyrtzidis
On Mar 20, 2013, at 7:24 AM, Fabien Sanglard <[hidden email]> wrote:

So the documentation at (http://clang.llvm.org/docs/UsersManual.html#usersmanual-precompiled-headers) should be disregarded  ?

There's some misunderstanding, what I said was that you should follow the documentation and use an -include "precomp_common.h" option.
 "precomp_common.h" should be multiple-includes-guarded (e.g. with a guard macro or "#pragma once") thus the #ifndef in

#ifndef __clang__
  #include "precomp_common.h"
#endif

will be unnecessary.


Fabien

On Mon, Mar 18, 2013 at 9:41 PM, Argyrios Kyrtzidis <[hidden email]> wrote:
On Mar 18, 2013, at 12:44 PM, fab <[hidden email]> wrote:

I am working on a cross-platform codebase on Clang/MacOS X that is also
compiled with Visual Studio on Windows and GCC on Linux.

The source code headers always include "precomp_common.h" at the top of each
header files. But according to the Clang documentation
(http://clang.llvm.org/docs/UsersManual.html#usersmanual-precompiled-headers)
Clang will NOT use the PCH in this case and no speed up will be performed
since it was not include via "- include".

Using Clang it seems the only way is to perform a conditional include:

1.
#ifndef __clang__
  #include "precomp_common.h"
#endif

2. Add "precomp_common.h" to the prefix header via -include option.

You don't need to do 1.; by doing 2. the "#include "precomp_common.h" will just be skipped.


I wonder if there is a "cleaner" way to do it.



--
View this message in context: http://clang-developers.42468.n3.nabble.com/Precompiled-header-without-prefix-header-tp4031029.html
Sent from the Clang Developers mailing list archive at Nabble.com.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev