[Qt-interest] Precompiled headers in Visual Studio

Donovan Parks donovan.parks at gmail.com
Tue Dec 15 14:42:39 CET 2009


Hey Alan,

I've found the following solution to work well for me which avoids
some of the hassle of using the -f flag. In the Advanced section of
the C/C++ project settings you can set "Force Includes" to your
precompiled header. This forces it to be inserted at the top of every
file.

Cheers,
Donovan

On Mon, Dec 14, 2009 at 2:55 PM, Alan M. Carroll
<amc at network-geographics.com> wrote:
> I will illustrate them using the presumed project file "header.hpp" from which is generated "moc_header.cpp". The question is how to get moc_header.cpp to include Precompiled.hpp.
>
> Make sure the Properties Windows is showing (use Alt-Enter if not).  Select the project in the solution explorer. In the property window you should see an entry labeled "MocOptions". You want to add to the front
>
> -fPrecompiled.hpp -f"../../$(InputFileName)"
>
> The ordering is important. The second -f is what makes moc_header.cpp include header.hpp which is required. I got burned because if no -f is specified it automatically includes the source header, but if you use -f to specify Precompiled.hpp you also lose that automatic inclusion. So you have to do both.
>
> What makes this painful is that you have to update this for every header already in the project. You can hand edit the custom build step, or you can just remove the header and then add it back.
>
> At 03:03 PM 12/13/2009, Donovan Parks wrote:
>>How can I modifying the
>>"moc'ing" of my project so it includes Precompiled.hpp instead of
>>StdAfx.h?
>
>




More information about the Qt-interest-old mailing list