Compile Error: Invalid String Conversion

Noob warning! I’m trying to compile an existing Windows/Mac project for Linux. Make stops at the inifileparser.h file with an error:

invalid conversion from ‘const juce::String*’ to ‘juce::String*’ [-fpermissive]

The error relates to the item “line” in the following code snippet:

String* getSection(const String& name) const noexcept {
auto line = lines.begin();
if (name.isEmpty()) return line;

Is there something obvious wrong here, or do I need to provide a whole lot more info?

OS: Linux Mint 21.1 (based on Ubuntu 22.04).
Project: Sower extension for Reaper, DLL written by nizzei8q in 2018.
Juce versions tried: 7.0.5, 6.0.8, 6.0.0, 5.4.5
Dependencies:
alsa - Installed libasound2-dev
freetype2 - Installed libfreetype6-dev
libcurl - Installed libcurl4-openssl-dev
webkit2gtk-4.0 - Installed libwebkit2gtk-4.0-dev
gtk±x11-3.0 - Installed libgtk-3-dev
g++ - Installed g++ (includes g+±11)

The input argument name is marked as const, but you’re trying to return a pointer to a String which is not const. The compiler is preventing you from doing this, as it would lead to undefined behavior.

A quick fix would be to change the return type to const String*, but it might be better be to re-think things a little bit. A pointer to a String is a risky thing to have, and there are probably better approaches to achieving your end goal. For instance, you could just return a new String which contains a sub-string of the original. This costs a little more in terms of performance, but has the advantage that the new string will never be corrupted if the old one disappears. Another approach would be to use std::string_view to represent your substring. This has the opposite effect: it doesn’t copy anything so it’s very fast, but it’s also not so safe. Both of these options are much better than returning a String*.

Thank you so much for your prompt response, Liam! Unfortunately, I’m way out of my depth here. I thought I’d already tried every permutation of “const” placements, but your suggestion certainly helped the process go much further than it had previously. Then, compiling failed with “argument discards qualifiers”, which I suspect confirms the concerns you mentioned.

Now, I see that there are a few other slip-ups in the code, including references to a missing image (which I’ve created) and min & max macros being defined (which they apparently shouldn’t be)…

My only hope of getting this jolly useful tool working on Linux, might be to beg the developer to revive a project with which he has lost interest.