Spectrum is now read-only. Learn more about the decision in our official announcement.


Eclipse Theia - Cloud & Desktop IDE


cpp extension with clangd

June 10, 2019 at 3:51pm

cpp extension with clangd

June 10, 2019 at 3:51pm
I tried using clangd 8 along with cpp extension. it works fine. But, I created a C file (not C++ file) with void main() method, clangd complains that return type of main() function should be int and not void. I would like to be able to add & implement "void main()" method. How can i do it? How can i add options to clangd to suppress certain warnings?

June 11, 2019 at 7:18am
Also, this link describes installing clangd on ubuntu: As theia docker image is based on node:10-alpine, it would be nice to get installation steps for node:10-alpine linux.
You can use a preference to pass some startup parameters to clangd, permitting the disabling of categories of warnings. For the example above, the following should work:
"cpp.clangdArgs": "-Wno-main-return-type"
We do not yet have a cpp docker image, but cpp is included in the "full" image (ubuntu-based):

June 17, 2019 at 3:57pm
Thank you, . Is the option "-Wno-main-return-type" an argument for clangd or a build option for clang compiler?

June 18, 2019 at 10:21am
It's a /cpp preference, that's used as a startup parameter to clangd.

July 25, 2019 at 6:41am
Hi , Thank you ! I tried the option "cpp.clangdArgs": "-Wno-main-return-type"
Here is the error that was logged:
root ERROR C/C++: clangd.exe: Unknown command line argument '-Wno-main-return-type'. Try: 'C:\Program Files\LLVM\bin\clangd.exe -help' clangd.exe: Did you mean '-completion-style'?
Confirmed - I get the same. I got fooled into thinking it worked because the diagnostics disappearing, but it did not work. As far as I can see, there is no way ATM to pass-on clang command-line arguments when starting clangd. Maybe asking the clangd community how to achieve this would be the way forward.

September 3, 2019 at 8:11am
I tried adding "-Wno-main-return-type" to compile_flags.txt file added to project root folder, it seems to work. Could you please confirm?

September 4, 2019 at 10:42am
I confirm. The only little thing is that a frontend reload is required to pick-up the new or updated compile_flags.txt file. Maybe /cpp should watch that file for changes and restart clangd when that happens.

September 5, 2019 at 3:22am
Thank you, . Is there an option to turn off error that is shown for include files not found?

September 5, 2019 at 12:07pm
can you provide code for an example of such an include error? Looking quickly I did not see a way to disable these errors, so the way forward might rather be to configure the project so that clangd can find these includes.

September 13, 2019 at 4:01am
specifying include file directories using -I option in compile-flags.txt solves the issue

September 16, 2019 at 8:10am
& others, is there a way to specify preprocessor directives to clangd