On 08/02/2020 18:00, avr-gcc-list-requ...@nongnu.org wrote:
Send AVR-GCC-list mailing list submissions to
        avr-gcc-list@nongnu.org

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
        avr-gcc-list-requ...@nongnu.org

You can reach the person managing the list at
        avr-gcc-list-ow...@nongnu.org

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 <col...@gmail.com>
To: avr-gcc-list@nongnu.org
Subject: Re: Where is the error (stdout)
Message-ID: <ba9626ca-b83b-3dd3-a139-7c1b025ab...@gmail.com>
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 <dke...@hiwaay.net>
To: avr-gcc-list@nongnu.org
Subject: Re: Where is the error (stdout)
Message-ID: <d907572a-3684-4331-94e5-a9a8363fd...@hiwaay.net>
Content-Type: text/plain;       charset=us-ascii


On Feb 7, 2020, at 5:58 PM, Col <col...@gmail.com> 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, dke...@hiwaay.net
============================================================
Whom computers would destroy, they must first drive mad.




------------------------------

Subject: Digest Footer

_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
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




Reply via email to