[En-Nut-Discussion] Error compiling the simplest program
Tim DeBaillie
debaillie at ciholas.com
Wed Mar 7 18:00:12 CET 2007
On Wed, 7 Mar 2007, Lorenzo Verniani wrote:
> void main (void)
> {
> printf ("Hello world!");
> }
You can't printf if you don't have a STDOUT device. You have to register
a device to STDOUT first. For example:
int main(void){
u_long baud = 115200;
//register the serial console
NutRegisterDevice(&DEV_UART, 0, 0);
uart = fopen(DEV_UART_NAME, "r+");
_ioctl(_fileno(uart), UART_SETSPEED, &baud);
fprintf(uart, "Hello World!");
for(;;)
NutThreadYield();
}
OTHER NOTES:
~ Use int main, instead of void main (Ethernut will thank you)
~ You can't let main exit, but you can let it infinite loop as above.
You can setup the serial to be the STDOUT device as well, but I don't have
that code handy at the present.
Tim
More information about the En-Nut-Discussion
mailing list