aros-development-team / AROS

Main AROS repository for active development. Contains the main Operating System components and Build System.
http://www.aros.org
Other
370 stars 60 forks source link

stdio: don't try to both define and prototype getchar #564

Closed robn closed 3 years ago

robn commented 3 years ago

In stdc, if _STDIO_H_NOMACRO is not set (default), getchar will be prototyped, and then immediately defined.

Later in posixc, if compiling with without NO_POSIX_WRAPPERS (that is, _XOPEN_SOURCE or _POSIX_SOURCE or _BSD_SOURCE is defined, see aros/features.h), getchar is prototyped again, except this time it is already a macro, and the preprocessor gets confused (it thinks void is an argument).

So, in stdc we force getchar to be either a prototype or a macro, and in posixc we only prototype getchar if its not already a macro.

The twisty maze of feature macros has done my head in, and I can't be sure what the impacts are, but I don't think it matters: ultimately, we compile clean and getchar is provided to any program that wants it in an ABI-safe way.