How to know if a project is C or C++ in Visual Studio?

c, c++, compiler-construction, visual-studio

Solution

Does VS use C compiler for C, and C++ compiler for C++ ?

No

the `cl` compiler is smart enough to know(based on file extension) if a file is a `.cpp` or `.cc` file - which it considers as C++ file. And the `cl` compiler will consider a `.c` file as a C program source file, and compile accordingly. Although it does load a separate `dll` file for compiling `C` and `C++` file. But this is implementation defined.

However, there is a switch to override the behavior of `cl` based on file extension.

To compile as C++ source file (even with extension of `.c`), command would be: `cl /TP yourfile.c` note however, the file should contain valid C++ code.

And to compile as C source file (with extension of `.cpp`), command would be: `cl /TC yourfile.cpp` note however, the file should contain valid C code.

Problem

How does Visual Studio know if a project is C or C++? Is there any configuration or build parameter that indicates this ? Does VS use C compiler for C, and C++ compiler for C++ ?

Original source