telling c from cpp files or making VS recognize c as c++
-
I downloaded a github project (SimVDI) and tried to compile it under VS 2013 (being the only VS I have). The author named all the files with extension .c. Almost all code is C but in one place the author seemed to let a sloppiness creep in and did some C++-ish thing (auto declaration in for (int i=0...)). I repaired that to C style. But is there a way to make S treat all files with extension .c as C++ files? (rather than nameing them .cpp)?
-
I downloaded a github project (SimVDI) and tried to compile it under VS 2013 (being the only VS I have). The author named all the files with extension .c. Almost all code is C but in one place the author seemed to let a sloppiness creep in and did some C++-ish thing (auto declaration in for (int i=0...)). I repaired that to C style. But is there a way to make S treat all files with extension .c as C++ files? (rather than nameing them .cpp)?
-
Add the
/TP
option to the compiler settings. See Compiler Options Listed by Category | Microsoft Docs[^]. -
Thanks. That helped partially. For the file in question it cured the problem. But it fired a cascade of other errors in other files. I choose the project settings and add the /Tp as an additional command line switch, right?
-
No, it is the /TP option (capital P). Please go to the link I gave you to see the difference.
OK thanks. Sorry for misunderstanding. It turns out that the author must have had the intention to mark all soource files being C-files (there was the option /TC alreay there). Overriding that with /TP triggers so many errors that I decided to leave in the /TC option, repair the error manually in that one C-file and will contact the author about that.