sba1 / adtools

Experimental GNU toolchain for AmigaOS
33 stars 18 forks source link

GCC 10: error: ‘strcasecmp’ was not declared in this scope #110

Open MBeijer opened 2 years ago

MBeijer commented 2 years ago

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!

sodero commented 2 years ago

How did you build the compiler? Are you cross compiling or building natively? What happens if you use -mcrt=clib2 instead?

sodero commented 2 years ago

Are you using using namespace std; / std::strcasecmp btw?

MBeijer commented 2 years ago

@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:

sodero commented 2 years ago

@MBeijer Does this work for you?

bild

Sorry about the weird way of showing example code. I have networking issues in my Amiga cave.

sodero commented 2 years ago

I would recommend using gcc 11 and clib2 btw. If you're using a native compiler you could pick these, gcc 11 and clib2.

MBeijer commented 2 years ago

I'm cross compiling from Linux. Will do some tests with your example code and get back to you with the results.

Message ID: @.***>

MBeijer commented 2 years ago

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: @.***>

capehill commented 1 year ago

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.

MBeijer commented 1 year ago

Ah, okay, this was probably when trying to compile MilkyTracker... Can't remember.

Message ID: @.***>