The Small Device C Compiler (SDCC) will produce a ihx (Intel Hex) file even if there are undefined reference errors during the link step. This behavior causes problems when using SDCC in a Makefile because if you set the ihx file to be your make target, then make has no good way of knowing that a previous attempt at linking has failed.
Is there a way to tell SDCC to suppress the ihx output when there is an undefined reference during linking? If not, what is the best workaround? (I already thought of one).
Also, I'm interested in why SDCC was designed this way if anyone knows.
Here's an example of the problem:
You have a file called test.c which calls an undefined function:
void foo();
void main()
{
foo();
}
You have a simple Makefile for building a test.ihx from test.c:
test.ihx: test.c
sdcc test.c
You try to compile test.c for the first time and it fails:
C:\test>make
sdcc test.c
?ASlink-Warning-Undefined Global '_foo' referenced by module 'test'
make: *** [test.ihx] Error 1
You try to fix the problem by changing something that is not a dependency of the ihx (such as the Makefile), and try to compile again:
C:\test>make
make: `test.ihx' is up to date.
But make doesn't try to compile it because SDCC already created the ihx file.