Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling precompiled headers for a specific file in a VC++ 2010 project

As the title says. I have a C++ project, and added 1 C .h file and a C .c source file, but they are having problems because the rest of the project uses a precompiled header, but if I try to include it in those C files, it gives an error. I can't just disable precompiled headers for the whole project, because it's part of a larger project that uses it and has code by somebody else.

So is there a way to select those two C files (the .h header and .c source files) and disable PCH?

Thanks.

like image 901
bitterman Avatar asked Feb 16 '12 20:02

bitterman


People also ask

How do I turn off precompiled headers?

To turn off precompiled headersSelect the Configuration properties > C/C++ > Precompiled Headers property page. In the property list, select the drop-down for the Precompiled Header property, and then choose Not Using Precompiled Headers.

Why do I get precompiled headers?

You can precompile both C and C++ programs. In C++ programming, it's common practice to separate class interface information into header files. These header files can later be included in programs that use the class. By precompiling these headers, you can reduce the time a program takes to compile.

Are header files precompiled?

In the C and C++ programming languages, a header file is a file whose text may be automatically included in another source file by the C preprocessor by the use of a preprocessor directive in the source file. Header files can sometimes contain very large amounts of source code (for instance, the header files windows.

Are precompiled headers worth it?

The advantage of precompiled headers is that the huge system library header files and other files that do not change at all or infrequently only have to be parsed once per build. As all C compilers (that I know of) work on every .


Video Answer


1 Answers

Highlight the file in the Solution Explorer and hit Alt+F7. This will bring up the properties for the file; in the "C/C++" section under "Precompiled Headers" you'll find the relevant options. You don't need to worry about the .h files.

like image 162
Mark Ransom Avatar answered Sep 18 '22 16:09

Mark Ransom