Implicit declaration of function

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Implicit declaration of function

3,167 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hjetschko on Sun Feb 03 17:13:31 MST 2013
I get a couple of "implicit declaration of function" warnings when I compile my code. I thought that these mean that the compiler cannot resolve a function name and is normally solved by including the correct header file and setting the correct include path. My code works but I am uncomfortable with warnings showing up. Below is the command called and the warnings:

arm-none-eabi-gcc -D__REDLIB__ -DDEBUG -D__CODE_RED -D__USE_CMSIS=CMSISv2p00_LPC11xx -I"D:\Projects\svn\Firmware\CMSISv2p00_LPC11xx\inc" -I"D:Projects\svn\Firmware\LaserRanger\src" -O0 -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -mcpu=cortex-m0 -mthumb -MMD -MP -MF"src/main.d" -MT"src/main.d" -o "src/main.o" "../src/main.c"
../src/main.c: In function 'main':
../src/main.c:29:2: warning: implicit declaration of function 'GPIOInit' [-Wimplicit-function-declaration]
../src/main.c:31:2: warning: implicit declaration of function 'StartLis500Clock' [-Wimplicit-function-declaration]

The header and source files are in the src folder which are included in the compiler call.
0 Kudos
Reply
1 Reply

2,791 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wrighflyer on Mon Feb 04 03:30:16 MST 2013
I'm currently working wit hLPC800 so these details may be slightly different but they may give you an idea where to look. For the LPC800 the GPIOInit() function is provided by the lpc8xx_gpio.c and documented by the lpc8xx_gpio.h in the lpc800_driver_lib. I imagine the structure is going to be similar for LPC11xx or LPC13xx or whatever.

So in the main.c I just use:
 #include <lpc8xx_gpio.h>

and this is further supported by the -I on the command line:
Invoking: MCU C Compiler
arm-none-eabi-gcc -D__REDLIB__ -DDEBUG -D__CODE_RED -D__USE_CMSIS=CMSIS_CORE_LPC8xx -D__LPC8XX__ -I"C:\Documents and Settings\asl\My Documents\LPCXpresso\workspace\lpc800_driver_lib" -I"C:\Documents and Settings\asl\My Documents\LPCXpresso\workspace\CMSIS_CORE_LPC8xx\inc" -I"C:\Documents and Settings\asl\My Documents\LPCXpresso\workspace\lpc800_driver_lib\inc" -Os -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -std=gnu99 -mcpu=cortex-m0 -mthumb -MMD -MP -MF"src/main.d" -MT"src/main.d" -o "src/main.o" "../src/main.c"

within that it's specifically:
-I"C:\Documents and Settings\asl\My Documents\LPCXpresso\workspace\lpc800_driver_lib"

that allows lpc8xx_gpio.h to be found.

Further to this I also have this in the link:
Invoking: MCU Linker
arm-none-eabi-gcc -nostdlib -L"C:\Documents and Settings\asl\My Documents\LPCXpresso\workspace\CMSIS_CORE_LPC8xx\Debug" -L"C:\Documents and Settings\asl\My Documents\LPCXpresso\workspace\lpc800_driver_lib\Debug" -Xlinker -Map="lpc8test1.map" -Xlinker --gc-sections -mcpu=cortex-m0 -mthumb -T "lpc8test1_Debug.ld" -o "lpc8test1.axf"  ./src/cr_startup_lpc8xx.o ./src/main.o   -lCMSIS_CORE_LPC8xx -llpc800_driver_lib

and within that:
 -L"C:\Documents and Settings\asl\My Documents\LPCXpresso\workspace\lpc800_driver_lib\Debug"

says where to look for a built copy of the library that contains GPIOInit() and the:
-llpc800_driver_lib

adds the library itself to the linked objects.
0 Kudos
Reply