[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] This must be an gcc / ld error!
Ole Loots wrote:
How to compile this code:
#include<string.h>
int main ( void )
{
char * x = "1235554444111abc";
char * y;
y = strchrnul(x, (int)'a');
return( 0 );
}
without missing references?
What do you call a "missing reference" ? A linker unresolved external ?
I use the CVS MiNTLib shipped with my cross-compiler and I don't get any
unresolved external.
However, by default strchrnul() is not declared in string.h. I causes a
warning, not an error :
$ m68k-atari-mint-gcc -Wall tst.c -o tst.tos
tst.c: In function 'main':
tst.c:7:2: warning: implicit declaration of function 'strchrnul'
tst.c:7:4: warning: assignment makes pointer from integer without a cast
Using a function without a prototype is allowed by the C language but should
be avoided, because arguments may be passed incorrectly.
There are a lot of nonstandard functions supported by the MiNTLib but not
declared by default. You can turn all these features on by defining _GNU_SOURCE.
$ m68k-atari-mint-gcc -Wall -D_GNU_SOURCE tst.c -o tst.tos
No more warnings, everything fine.
--
Vincent Rivière