String.endsWith() flagged as param type mismatch in AppCode

Hey there

JetBrains AppCode (Mac) seems to think that String.endsWith(juice::String) is error-worthy.

Specifically I get this:
Parameter type mismatch: Types 'StringRef' and 'const char[5]' are not compatible

If I allow AppCode to “fix” the JUCE source it results in a change that doesn’t even compile. I can suppress such warning, but I’m wondering why these are even happening in the first place.

Thoughts, anyone?



What JUCE ver and toolchain (and version) are you using? String::endsWith takes a StringRef, which whatever toolchain you’re using is struggling to implicitly convert from a const char* to a StringRef.

I know this issue as a clang-tidy warning displayed in the IDE. However, it’s no compiler error or warning, so it should be safe to simply ignore it. clang-tidy offers you a lot of useful suggestions on how to optimise your code, but in the end you always have to keep in mind that it can be wrong or irrelevant for your use-case.

So are you really getting a hard compiler error or just a clang-tidy message?

Hey @jrlanglois thanks for the quick reply. I’m using JUCE 6.0.8 (04fdc4c20 / 9 April).

I’m not sure what toolchain/version I’m using - how can I find that out? I see Projucer is set for the MacOS Base SDK version, but that’s probably not what you mean. :confused:

Some anecdotal bits of info though.
a) The same line in the same project with Xcode does not present any warning.
b) I have seen this warning in AppCode quite some time ago in other projects but I wasn’t using it seriously then so didn’t care. My point here is this “issue” isn’t necessarily new.
c) Using the following obviously suppresses the problem, but I’d like to actually understand it.

#pragma clang diagnostic push
#pragma ide diagnostic ignored "IncompatibleTypes"



Hey @PluginPenguin, yes you’re quite right, it does not cause a fail-condition compiler error. More I’m just perturbed by seeing the errors flying around telling me I’m doing something wrong (which I often am tbh).

I understand that I am free to keep working and ignore it, but is that the right thing for me to do? It feels like I should be telling someone so it can be fixed at some point. I don’t know whom that should be though.

It’s a known AppCode bug and you should report it to JetBrains:

While that’s not always a possible solution, I think CLion is a more mature C++ IDE than AppCode, and it has superior syntax parsing (so doesn’t have that StringRef bug).

1 Like

Thanks for the reply and suggestion @eyalamir.
I’ve not filled in one of those reports before. Hopefully this covers what’s necessary. Please feel free to correct or clarify anything I’ve said.

I think you need to send them a minimal self contained project with an example.

You can upload zip files to that bug tracker, just make sure it uses relative paths and will open on machines that aren’t yours (without them having to launch the Projucer, which they probably won’t).