We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I want to use the printf() to print characters on LCD, via serial port, 7-segment. I want to change this in runtime.
My idea was to change the member "handle" of stdout during runtime. In the function fputc(), I can call the correct routines using a switch(f->handle) statement.
I modified the __stdout as follows.
struct __FILE { int handle; /* Add whatever you need here */ }; FILE __stdout; #define LCD 1 #define RS232 2 #define SEVENSEGMENT 3 void main(void) { stdout->handle = LCD; printf("TEST"); } int fputc(int ch, FILE *f) { switch (f->handle) { case .. case .. } return (ch); }
I got the error "pointer to incomplete classtype is not allowed.
What 's wrong with this ?
Luc.
You are declaring something named __stdout and then later using something named stdout. If the compiler doesn't complain that stdout is an unknown symbol, then one of your include files may have defined stdout to be something else (a partial or full declaration).