I have some old code files in my C project, that need to be compiled as C code - the entire codebase is set to compile as C .
I am using Visual Studio, but I'd rather avoid setting this per-file from the project properties, and would rather use some kind of #pragma
directive (if possible).
I have searched around, but found nothing, the closes I could think of is to add an #ifdef
, that checks for __cplusplus
and fails if does so.
Basically I am looking for a way to inject the /Tc, /Tp, /TC, /TP (Specify Source File Type) commands from the source.
CodePudding user response:
"By default, CL assumes that files with the .c extension are C source files and files with the .cpp or the .cxx extension are C source files."
So rename the files if nessesary and put the new c files to your projekt.
If neded set the compiler options: Set compiler