Re: AVR-GCC-list Digest, Vol 157, Issue 2
Bob von Knobloch <[email protected]> Tue, 11 Feb 2020 13:31:58 +0100
| Newsgroups | gmane.comp.hardware.avr.gcc |
|---|---|
| Message-ID | <[email protected]> |
On 08/02/2020 18:00, [email protected] wrote: > Send AVR-GCC-list mailing list submissions to > [email protected] > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.nongnu.org/mailman/listinfo/avr-gcc-list > or, via email, send a message with subject or body 'help' to > [email protected] > > You can reach the person managing the list at > [email protected] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of AVR-GCC-list digest..." > > > Today's Topics: > > 1. Re: Where is the error (stdout) (Col) > 2. Re: Where is the error (stdout) (David Kelly) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sat, 8 Feb 2020 12:58:19 +1300 > From: Col <[email protected]> > To: [email protected] > Subject: Re: Where is the error (stdout) > Message-ID: <[email protected]> > Content-Type: text/plain; charset=utf-8; format=flowed > > >> >> void uart_putchar(char c, FILE *stream) >> { >> if (c == '\n') >> uart_putchar('\r', stream); >> loop_until_bit_is_set(UCSRA, UDRE); >> UDR = c; >> return ; >> } >> > I suspect it's because your returning a void instead of an int, > > Here is some code that I used to test stdio on avrlibc ( atmega128 ) > > which compiles fine with gcc 5.4.0 > > > static int uart_putchar(char c, FILE *stream) > { > if (c == '\n') > uart_putchar('\r', stream); > loop_until_bit_is_set(UCSR0A, UDRE); > UDR0 = c; > return 0; > } > > > > > Cheers > > Colin > > > > > > ------------------------------ > > Message: 2 > Date: Fri, 7 Feb 2020 18:56:41 -0600 > From: David Kelly <[email protected]> > To: [email protected] > Subject: Re: Where is the error (stdout) > Message-ID: <[email protected]> > Content-Type: text/plain; charset=us-ascii > > > On Feb 7, 2020, at 5:58 PM, Col <[email protected]> wrote: > >>> void uart_putchar(char c, FILE *stream) >>> { >>> if (c == '\n') >>> uart_putchar('\r', stream); >>> loop_until_bit_is_set(UCSRA, UDRE); >>> UDR = c; >>> return ; >>> } >> >> I suspect it's because your returning a void instead of an int, > > In Unix convention its > > int putc( int, FILE* ) > int putchar( int ) > > Where upon success one returns the character put or -1 or EOF for failure. If replacing standard function one should return the expected value else something will break. > > -- > David Kelly N4HHE, [email protected] > ============================================================ > Whom computers would destroy, they must first drive mad. > > > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > AVR-GCC-list mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/avr-gcc-list > > > ------------------------------ > > End of AVR-GCC-list Digest, Vol 157, Issue 2 > ******************************************** > I use a similar function on a Mega1284: /** ******************************************************************************* * Wait until USART free, then send character to the terminal. * Pad LF to CR,LF. ******************************************************************************* */ static void term_putchar(uint8_t c) { if (c == '\n') term_putchar('\r'); loop_until_bit_is_set(UCSR0A, UDRE0); UDR0 = c; } Compiles and works fine (for me), possible the spurious 'return;' is doing something that the compiler doesn't like (need a GCC guru). Cheers, Bob