Problem trying to implement a putchar function
I need to implement my version of putchar function to work with MSP430 UART ISR.
The problem is that if I try to create the function __putchar(int c) the compiler show error with "redeclaration of '__putchar'..." and if I try to creat _putchar(int c) it said "undefined symbol '___putchar'" when I use printf function.
-
Be careful that there are two underscores at the start of the name __putchar()
Another point is that __putchar should return an int, so in a header file that you use the prototype would be:
int __putchar(int c);
Then in ONE .c file that you link into your project, have the definition
int __putchar(int c) {
/* whatever you need to do to send the character c to the MSP430 uart */
return c;
}
Please sign in to leave a comment.
Comments
1 comment