GP32 Implicit Declaration


pea

developer
Joined
Oct 3, 2004
Messages
1,089
Age
46
Location
New Zealand
Website
www.projectitis.com
Hey all,

For some reason I am having a compile problem trying to add some custom code to Mr.Mirko SDK (actually upgrading from an older version of the SDK, and adding my custom functions back in - so they worked previously).

The problem I am having is that the functions malloc, free, memcpy etc don't seem to be defined or something:

Code:
arm-elf-gcc -I../../include -O2 -s -Wall -mtune=arm9tdmi   -c -o gp_input.o gp_input.c
gp_input.c: In function `_gp_inputKeyCreate':
gp_input.c:29: warning: implicit declaration of function `malloc'
gp_input.c: In function `gp_inputCreate':
gp_input.c:121: warning: implicit declaration of function `memset'
gp_input.c: In function `gp_inputFree':
gp_input.c:135: warning: implicit declaration of function `free'
gp_input.c: In function `gp_inputGetChatBuffer':
gp_input.c:178: warning: implicit declaration of function `memcpy'
arm-elf-ar rcs gp_input.a gp_input.o
cp gp_input.a ../../lib/
rm *.o *.a

I have succesfully compiled other custom parts of the SDK that contain references to these functions with no problems. The only #include in any of these units is <gp32.h> and the makefiles seem to be identical as far as I can tell.

Any ideas?
 
Sorry, just added -Wall to the CFLAGS, and now the other code also gets the same warning!

I will change my question to:
When I compile my custom code, I get the above 'implicit declaration' errors. Is this bad??
 
Are you linking properly with whatever libraries you need, and have you #included all of the headers you need for malloc and friends??

Implicit declaration usually means that it has no idea what that name stands for (as it hasn't been defined yet).

It's also possible the name of malloc and such have changed with new API updates, I seem to remember that the vector MAME thread mentioned that some of the names of the malloc calls had to be changed.

Edit: Yeah, this thread says you should rename malloc to gm_zi_malloc and free to gm_zi_free, though I don't know if that has anything to do with mirko's sdk.
 
Last edited by a moderator:
Thanks ravuya. I think the warning must be ok, and I can leave it to the linker to sort it alll out.

I think that the gm_ functions relate to the official SDK? I've never used them anyway.
 
pea posted on Jul 19 2005 at 03:25 AM said:
Hey all,

For some reason I am having a compile problem trying to add some custom code to Mr.Mirko SDK (actually upgrading from an older version of the SDK, and adding my custom functions back in - so they worked previously).

The problem I am having is that the functions malloc, free, memcpy etc don't seem to be defined or something:

Code:
arm-elf-gcc -I../../include -O2 -s -Wall -mtune=arm9tdmi   -c -o gp_input.o gp_input.c
gp_input.c: In function `_gp_inputKeyCreate':
gp_input.c:29: warning: implicit declaration of function `malloc'
gp_input.c: In function `gp_inputCreate':
gp_input.c:121: warning: implicit declaration of function `memset'
gp_input.c: In function `gp_inputFree':
gp_input.c:135: warning: implicit declaration of function `free'
gp_input.c: In function `gp_inputGetChatBuffer':
gp_input.c:178: warning: implicit declaration of function `memcpy'
arm-elf-ar rcs gp_input.a gp_input.o
cp gp_input.a ../../lib/
rm *.o *.a

I have succesfully compiled other custom parts of the SDK that contain references to these functions with no problems. The only #include in any of these units is <gp32.h> and the makefiles seem to be identical as far as I can tell.

Any ideas?

warning: implicit declaration of function `memcpy'
This means that gcc can not find the prototype for memcpy, but compiles without an error.
I guess you are using an old gcc compiler, couse my gcc 3.4.3 bombs no warnings about this.

You can solve this warnings, by adding the #include <blubb> for the missing prototypes.
Or use -Wno-implicit in your makefile.
 
Last edited by a moderator:
pea posted on Jul 19 2005 at 04:14 AM said:
Thanks ravuya. I think the warning must be ok, and I can leave it to the linker to sort it alll out.

I think that the gm_ functions relate to the official SDK? I've never used them anyway.

use #include <stdlib.h>

implicit declarations are bad(tm)
 
Last edited by a moderator:
hehe. Thanks guys.

Mr.Mirko - How do I tell which version of GCC I have? I am using the latest (r14) of devkitARM.

I have set warnings to -wAll so I could cull out unused vars etc.
 
pea posted on Jul 19 2005 at 08:00 PM said:
hehe. Thanks guys.

Mr.Mirko - How do I tell which version of GCC I have? I am using the latest (r14) of devkitARM.

I have set warnings to -wAll so I could cull out unused vars etc.

MrMirko seems to like to switch warnings off.

Some of us like to see what we've potentially done wrong.

With implicit declaration warnings switched off you run the risk of calling functions with the wrong parameters. Personally I'd rather see the warning than spend 2 days trying to debug an app that passes something dodgy when the compiler would have caught it had the warning been enabled.

you can tell which version by using arm-elf-gcc -v. devkitARM r14 is 3.4.4
 
Last edited by a moderator:
-Wall is good -- I generally dont' trust code that doesn't use full warnings. Relying on implicit decl's is really bad mojo :)

jeff
 
Back
Top