Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile C files in C++ project which do not use precompiled header?

People also ask

Do I need precompiled headers?

Usage of precompiled headers may significantly reduce compilation time, especially when applied to large header files, header files that include many other header files, or header files that are included in many translation units.

What if we dont use header files in C?

If you don't the compiler will use the default prototype for undeclared functions, which is: int functionName(int argument); So it will compile, and link if the functions are available. But you will have problems at runtime.

Do you need to compile header files C?

You don't need to compile header files. It doesn't actually do anything, so there's no point in trying to run it. However, it is a great way to check for typos and mistakes and bugs, so it'll be easier later.


In the Solution Explorer window right click on the *.c file(s) and select Properties. Go to C / C++ -> Precompiled Headers and set the Precompiled Header option to Not Using Precompiled Headers.

Also, unless you actually need precompiled headers, I'd say turn it off project-wide.

Another option would be to compile your C files as C++ and keep using the precompiled headers. To do that, right click on the project name (or each .c file name), and set C / C++ -> Advanced -> Compiles As to Compile as C++ code.