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.
Is there a way to prevent getchar from echoing the input characters? I tried to write my own implementation of getchar, but the linker doesn't seem to let me do that. - Mike
I wanted to be able to use scanf without the echo. It seems like the only way is to replace getchar and ungetchar in the standard library using the library manager. OK, I'll use sscanf instead. But wouldn't it be nice if Keil allowed us to change the implementation of getchar and ungetchar? - Mike
My "char getchar(void){return 0;};" links just fine. What error message are you getting?
I've taken the Traffic example. If I put "char getchar(void){return 0;}" in Serial.c, at link stage I get *** ERROR L104: MULTIPLE PUBLIC DEFINITIONS SYMBOL: getchar MODULE: C:\KEIL\C166\LIB\C167S.LIB (GETCHAR) *** ERROR L118: REFERENCE MADE TO ERRONEOUS EXTERNAL SYMBOL: getchar MODULE: C:\KEIL\C166\LIB\C167S.LIB (SCANF) ADDRESS: 07A6H
"I wanted to be able to use scanf without the echo. It seems like the only way is to replace getchar..." Why not use _getkey to read into a buffer, and then sscanf?
This work fine for me. Have you declared your getchar exactly the same way as the one that is provided in the /LIB folder? Jon
It works for me as soon as I comment out all references to scanf. When scanf gets linked to the program, it references getchar, this is where the trouble starts. There is no point for me in having custom getchar without scanf. Everything is fine with _getkey and putchar. Obviously, these names are recognized by the linker and treated differently from other symbols. - Mike
I've taken the Traffic example. If I put "char getchar(void){return 0;}" in Serial.c, at link stage I get *** ERROR L104: MULTIPLE PUBLIC DEFINITIONS I believe the reason for the error is that the function is defined as:
extern signed char getchar (void);
Actually, redefining getchar and ungetchar at the same time did the trick. I should have done that in the first place, so stupid of me. Thanks to everyone! - Mike