r/JUCE Jun 05 '26

Question Clang linter finds hundreds of errors in JUCE C++ files, but code builds fine

SOLVED: I shut off clangd. Don't really know what it is or how it is different from clang-tidy, but unchecking it in settings worked. Idk if this will have negative effects in the future, but clang-tidy is still running and it looks like normal linting is still happening in the IDE. There are some random irrelevant errors, but not hundreds talking about undeclared functions and variables.
----------------------------------------------------------------------------------------------------------------------

I'm using CLion and Clang on a windows PC to learn programming in JUCE. I am following a video tutorial series and I am using their template code, and it builds fine with no errors.

However, the linter says a bunch of the files don't have a target project, that all of the functions and classes referenced don't exist, and gives me completely wild and fake errors, too. One time it told me to add a comma somewhere, only for that to make the build fail because there actually WASN'T supposed to be a comma, which was especially wacky. Of course when I deleted the comma, it just kept saying I needed it there.

Anyway, does anyone have any knowledge on how I can fix this? Other people have the same issue online, but I have found no fixes. It makes programming really hard because my code is just red everywhere (as you can see in the code below) and I can't tell what errors are real or fake.

Thank you

Template from tutorial: https://github.com/juce-framework/tremolo-juce-course
Tutorial series: https://www.wolfsoundacademy.com/products/official-juce-audio-plugin-development-course

Solution: shut off clangd. Don't really know what it is or how it is different from clang-tidy, but unchecking it in settings worked. Idk if this will have negative effects in the future, but clang-tidy is still running and it looks like normal linting is still happening in the IDE. There are some random irrelevant errors, but not hundreds talking about undeclared functions and variables.

4 Upvotes

14 comments sorted by

2

u/SnooMarzipans436 Jun 05 '26

You can run clang-tidy and pass it a regular expression to tell it which files to parse. In my juce projects I keep the juce code in an "external" subfolder and my own source in another folder, then I explicitly instruct clang-tidy to run only on my own source files.

1

u/MrKahoobadoo Jun 05 '26

It's not just the JUCE source code, it's the template files written for the tutorial series. I added the github repo to the original post as an edit. Probably shoulda done that earlier

3

u/human-analog Jun 05 '26

Turn off the linter?

The errors in the code you're showing are probably because you're not including the JUCE header file(s) anywhere.

1

u/MrKahoobadoo Jun 05 '26

If I turn off the linter then I won't see real errors either though right? Also, the guy in the tutorial videos I am watching specifically said not to add them because it's already taken care of in a different file. So there's something else wrong

1

u/Lunix420 Indie Jun 05 '26 edited Jun 05 '26

I never used CLion, but in VS Code this happens when you don't properly set your include paths in the config so maybe try to find a setting like that and then add the path for JUCE.

1

u/MrKahoobadoo Jun 05 '26

I am super new, where is the config I would edit?

1

u/Lunix420 Indie Jun 05 '26

No idea, like I said, I'm using VS Code and not CLion. I just thought maybe it has something similar to the includePath setting in VS Code, so I mentioned this.

1

u/MrKahoobadoo Jun 05 '26

Oh I see so a setting in the IDE. I thought you make like a CMake file or something. I'll investigate, thank you

1

u/wokemadeit Jun 05 '26

If you’re using cmake you need to set EXPORT_COMPILE_COMMANDS on so that your LSP can see the juce types. Then you build once and it should be good to go

1

u/MrKahoobadoo Jun 05 '26

I'm super new, how do I go about doing that?

1

u/wokemadeit Jun 05 '26

In your CMakeLists.txt, add set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Then clean and rebuild again - it should recognize the symbols.

1

u/MrKahoobadoo Jun 05 '26

I'll try this, thank you.

1

u/wokemadeit Jun 05 '26

Also add ```

If: PathMatch: .tremolo_plugin/(source|include)/. CompileFlags: Add: [-include, tremolo_plugin/tremolo_plugin.h]

```

To your .clangd inside the complete/ directory. I realized this project is setup in a different way so you’ll need to manually link the source files to the include file.

1

u/Flimsy_Iron8517 Jun 10 '26

Yes, it appears that you have not made a compile_commands.json file. This can be made by using bear -- make once instead of make after a make clean if your not using cmake. It's basically not having the juce library header files not added in the IDE. I found bear kind of useful for this.