Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conflict with previous declaration of 'putchar' #57

Open
pklapperich opened this issue Oct 10, 2019 · 3 comments
Open

conflict with previous declaration of 'putchar' #57

pklapperich opened this issue Oct 10, 2019 · 3 comments

Comments

@pklapperich
Copy link

Unable to build with sdcc 3.9.0:

CC radio/golay.c
CC radio/serial.c
radio/serial.c:541: error 98: conflict with previous declaration of 'putchar' for attribute 'type' at /usr/bin/../share/sdcc/include/stdio.h:86
from type 'int function ( int fixed) fixed'
  to type 'void function ( unsigned-char fixed) __reentrant fixed'
make[1]: *** [include/rules.mk:135: obj/rfd900a/radio~rfd900a/serial.rel] Error 1
make[1]: Leaving directory '/home/paulk/botlink/SiK/Firmware'
make: *** [Makefile:95: install~radio~rfd900a] Error 2

I changed the signature in serial.c to

int                                                                                                 
putchar(int c) __reentrant

and it's working fine for me. But I suspect there's a more correct fix.

I found what looks like the same issue on the sdcc mailing list from 2007, but the PUTCHAR definition doesn't exist, so the reply there was unhelpful.

@spth
Copy link

spth commented Oct 21, 2019

This should be correct:

int
putchar(int c) __reentrant
{
	if (c == '\n')
		_serial_write('\r');
	_serial_write(c);
	return c;
}

By the C standard, putchar() takes an int, and returns it (using an int allows for error reporting, by returning EOF).

@AndKe
Copy link
Contributor

AndKe commented Oct 21, 2019

Thank you, this stopped me too.
With SDCC 3.8 , I needed to remove "-Werror" to get it compiled, - did you need it removed with 3.9 ?

@spth
Copy link

spth commented Oct 21, 2019

I had to remove it for SDCC 3.9.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants