I'm sure I don't see something obvious, but here it is :
I've written a small tools.h file containing 2 macros I use in several files of my project :
#ifndef _TOOLS_H_
#define _TOOLS_H_
#define is_in_range(x, a, b) ((x) >= (a)) && ((x) < (b))
#define clamp(x, a, b)\
(((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x)))
#endif
I added a #include "tools.h"
in every source file using clamp
and is_in_range
, but they seem ignored at compilation.
For example,
C:/SGDK134/bin/gcc -m68000 -Wall -fno-builtin -Iinc -Isrc -Ires -IC:/SGDK134/inc -IC:/SGDK134/res -BC:/SGDK134/bin -O3 -fuse-linker-plugin -fno-web -fno-gcse -fno-unit-at-a-time -fomit-frame-pointer -flto -c src/camera.c -o out/src/camera.o
src/camera.c: In function 'camera_set_focus':
src/camera.c:130:6: warning: implicit declaration of function 'clamp' [-Wimplicit-function-declaration]
x = clamp(fix32ToInt(obj->x) - 128, 0, current_stage.pwidth - 320);
I have several others, one for each source file referring to tools.h
.
And, of course, the compilation aborts:
C:/SGDK134/bin/gcc -BC:/SGDK134/bin -n -T C:/SGDK134/md.ld -nostdlib out/sega.o @out/cmd_ C:/SGDK134/lib/libmd.a C:/SGDK134/lib/libgcc.a -o out/rom.out
C:\Users\xxxx\AppData\Local\Temp\cczl66At.ltrans0.ltrans.o: In function `main':
.text.startup+0x3ec): undefined reference to `clamp'
.text.startup+0x972): undefined reference to `clamp'
.text.startup+0x9c8): undefined reference to `clamp'
.text.startup+0xb5c): undefined reference to `is_in_range'
.text.startup+0xce0): undefined reference to `clamp'
make.exe": *** [out/rom.out] Error 1
What am I missing?