adtools
adtools copied to clipboard
GCC 10: error: ‘strcasecmp’ was not declared in this scope
Hi!
I'm having trouble compiling a program since I updated to GCC 10, where I get the error
error: ‘strcasecmp’ was not declared in this scope
even though I have these includes:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <strings.h>
or these:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
with -mcrt=newlib
I looked at the newlib includes and they seem to define the function, so it seems like it's not loading the proper includes from newlib for some reason.
I hope someone can help out with this!
How did you build the compiler? Are you cross compiling or building natively? What happens if you use -mcrt=clib2
instead?
Are you using using namespace std;
/ std::strcasecmp
btw?
@sodero no, I'm not using using namespace std;
nor std::strcasecmp
but I tried using that now and I get this error instead:
error: ‘strcasecmp’ is not a member of ‘std’; did you mean ‘strcasecmp’?
:sweat_smile:
@MBeijer Does this work for you?
Sorry about the weird way of showing example code. I have networking issues in my Amiga cave.
I would recommend using gcc 11 and clib2 btw. If you're using a native compiler you could pick these, gcc 11 and clib2.
I'm cross compiling from Linux. Will do some tests with your example code and get back to you with the results.
Message ID: @.***>
Strange, with that test code it worked fine with -athread=native -mcrt=newlib
and -athread=single -mcrt=clib2
It's really strange that the code I compile to get the error has the same
includes + -athread=native -mcrt=newlib
.
The same code compiles just fine with both the MorphOS cross toolchain and
Bebbo's m68k toolchain without issue.
Message ID: @.***>
In case you were building with -std=c++11 (or later), try -std=gnu++11. In newlib, strcasecmp and some other functions are not available if STRICT_ANSI is defined.
I have seen similar problem when building MilkyTracker. First I tried -U__STRICT_ANSI__ which works around it, but gnu++11 is probably a cleaner solution.
Ah, okay, this was probably when trying to compile MilkyTracker... Can't remember.
Message ID: @.***>