2

GNU GCC compiler will compile c++ source files with both .C and.cpp extension.

Is it possible to configure Microsoft Visual Studio so that it could compile the c++ source and header files with extensions .C and .H extension respectively?

0

2 Answers 2

4

The problem is that the Windows file system is not case-sensitive, so there's no difference between .c and .C. This means that the default C language for .c will always apply.

You cannot tell the compiler to generally treat .C files as C++, however you can tell it to treat files in a a compilation command as C++ regardless of their extension with the /TP switch.

Sign up to request clarification or add additional context in comments.

2 Comments

Does that mean it is impossible to compile with .C extension in MVS?
It's possible, but you have to override the compiler default by setting every file to C++ in the project options.
4

The command line option /TP tells the compiler to treat the source files as C++, even if the extension is something like .c.

In the IDE, you can set this as one of the project properties. Under C/C++, select Advanced Options and set the "Compile As" fields to C++.

1 Comment

Does that command line option tell the MVS compiler to treat the source files with .C extension as c++ ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.