selective linking of floating point support for *printf / *scanf

Joseph S. Myers
Tue Sep 2 15:28:00 GMT 2014

On Tue, 2 Sep 2014, Joey Ye wrote:

> Apparently newlib is not following this specification very well, as
> there are symbols like _abc_r defined every where in current newlib. I
> am not implying the spec should not be followed, but is newlib
> designed to have a loose spec for the single underscore?

Identifiers beginning with a single underscore are reserved with file 
scope.  This means an application cannot provide an external definition of 
them, because such an external definition would have file scope.  So it's 
fine for the implementation to define such identifiers and use them in the 
implementation of standard functions.

You do still need to be more careful with them than with _[_A-Z]* 
identifiers.  For example, you can't do

#define standard_function(x) _standard_function(x)

in your libc headers, because the user's application could legitimately 
define a variable called _standard_function at block scope, then try to 
call standard_function within that block.  So in general it's safer to use 
the double underscore in the implementation, unless there is some clear 
reason to use the single underscore.

Joseph S. Myers

More information about the Newlib mailing list