On Wed, Oct 05, 2011 at 01:16:26PM -0400, Theo Tijssen wrote: > Hello! I have a simple program in C language that I was hoping to compile in > the SDCC compiler so I could download it onto my 8051 microcontroller. The > code is: > * > /* Hello World program */ > > #include<stdio.h> > > main() > { > printf("Hello World"); > > }* > > The issue I am having is when I compile this in SDCC, the error reads: > *?ASlink-Warning-Undefined Global '_putchar' referenced by module 'vprintf'* > > I tried putting in a general putchar code but that didn't work, it just gave > me more errors in the compiler. Do you know how to fix this or what we need > to add to our code in order for the compiler to properly compile it? Any > help and/or suggestions are appreciated. > > Thanks in advance!
You neet to provide a putchar that will use a suitable output channel for your hardware. Assuming the UART is already initialized (and if not you would need to add the code to initialize it before this gets called but that is hardware specific to your hardware) something like this should work. void putchar (char c) { while (!TI) ; TI = 0; SBUF = c; } main() { /* code to initialize the UART and set the baud rate here! */ printf("Hello World"); } Peter Van Epp ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user