Can you compile C files as C++ in CLion?

已回答

I have a mixed project, in which I wish to compile C files as C++.
I tried: 

project(derproject LANGUAGES CXX)

and

set_source_files_properties(yo/foo.c PROPERTIES LANGUAGE CXX)

but the C files are still compiled as C. Did I miss anything or is it a CLion's limitation?

MacOS, clang.
I get a warning:
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
but the object file produced uses C name mangling.

0

Hi!

The warning is unfortunate (CMake doesn't add the `-x c++` flag when compiling the c file with the c++ compiler). I suggest you to either file a bug in the CMake tracker or pass the flag manually. Other than that, I can't reproduce the issue in my environment (i.e. `nm` shows C++ mangled names for the generated object files). Could you please send us the project and describe how to observe the incorrect behaviour (clion-support at jetbrains.com)?

0

请先登录再写评论。