How does the cl compiler know whether I'm compiling C or C++ code?
Do I need to tell the compiler?
I am running out of the Developer Command Prompt for VS2015. I originally started this project with c++ code that compiled and ran on a RedHat Linux PC. I moved it to WIN7 and it would not compile under the cl compiler unless I got rid of the c++ constructs and implemented C equivalents.
A constructor in a header file was one of the issues I had to work around.
As documented in MSDN, it first looks at the filename extension. If it is .cpp or .cxx then it defaults to C++ compilation. Almost always good enough to get the job done. That same page also shows how to force the selection, use /Tc for C and /Tp for C++. You'd use /TC and /TP to force it for all source files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With