By default CLion C and C++ files has united file type in Settings->Editor->File Types But in inspect code .c file recognize as plain C (for example type bool requires the inclusion < stdbool.h >) but actually it must be compiled as C++
Help->About: CLion CL-140.2310.6 Build #CL-140.2310, built on February 12, 2015 ...
Put
SET_SOURCE_FILES_PROPERTIES(${SOURCE_FILES} PROPERTIES LANGUAGE CXX)
in your CMakeLists.txt
.
As commented by user7610 below this seems not to work when clangd completion is enabled (though I haven't confirmed it yet).
insert ""-xc++","
to [].arguments[1]
in compile_commands.json
.
--- compile_commands_original.json 2022-03-10 12:08:05.025572787 +0900
+++ compile_commands.json 2022-03-10 12:09:16.250045217 +0900
@@ -12663,6 +12663,7 @@
{
"arguments": [
"g++",
+ "-xc++",
"-c",
"-std=c++11",
"-fno-PIE",
(This happens when I build gcc with bear.)
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