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
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
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);
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
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
"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?
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
My "char getchar(void){return 0;};" links just fine. What error message are you getting?
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
use _getkey instead?
Use: char getchar (void); Instead of: int getchar (void);
View all questions in Keil forum