NBC/NXC on the LEGO NXT “Error: Undefined Identifier printf”

This had me mystified for a few hours: converting some old C code that worked on BrickOS with the gcc toolchain to use the Not-eXactly-C from bricxcc. The c sources must be compiled with the Next Byte Code compiler nbc. The c source file must have the file extension .nxc. I could see in the NXC Programmer’s Guide that printf is listed as a “Standard-C API function“, that nxc has a ‘cstdio API‘ which contains printf and a #include preprocessor command, but I couldn’t find a ‘cstdio.h’ anywhere.

The solution is to check the nbc command line arguments with:

nbc -help

and see the ‘-EF’ switch for ‘Enhanced Firmware’. A command line like:

nbc -EF testprintf.nxc -O=testprintf.rex

will JustWork™

Leave a Reply

Your email address will not be published. Required fields are marked *