C++ code inside .c file

Hi,

I know it's wrong and etc...
But for couple of reasons I'm handling with files with .c extension, which have also c++ content inside of them.
I compile it successfully with g++.

CLION give lots of visual errors every place in the .c files which has a c++ reference (for instance, when using the reference '&' sign).

Is there a place to tell CLION to treat .c files as .cpp files?
Or something similar which has more sense?

Thanks

6 comments
Comment actions Permalink

Hi Yogev!

Could you please describe how did you add your .c files in CMakeLists.txt and how do you get CMake to compile it using g++. It may affect the way CLion threats those files.

0
Comment actions Permalink

I acctually compile it with an external makefile.

In the CMakeLists.txt I added those files with file(GLOB_RECURSE...

0
Comment actions Permalink

Hi Yogev.

Sorry for the delay. Do you still have the problem?

0
Comment actions Permalink

Hi,

Hmm, do you mean, with the new clion version?

0
Comment actions Permalink

Please try using the following command in CMakeLists.txt:

 
SET_SOURCE_FILES_PROPERTIES(your_file.c PROPERTIES LANGUAGE CXX)


Does that help?

1
Comment actions Permalink

It works! Great! Thanks!

0

Please sign in to leave a comment.