[PATCH] Add missing headers to fix implicit function defns

Hans-Bernhard Bröker HBBroeker@t-online.de
Tue Jan 17 18:22:00 GMT 2017


Am 17.01.2017 um 11:08 schrieb Sebastian Huber:
> On 16/01/17 22:21, Hans-Bernhard Bröker wrote:
>> Am 16.01.2017 um 01:12 schrieb Pat Pannuto:

>> If a header defines macros which reference things provided by other
>> headers, it should make sure those other things are known, i.e. it
>> should include those other headers.

> No, this would lead to cyclic dependencies (<stdlib.h> includes
> <sys/reent.h>) and would make <string.h> and <stdlib.h> unnecessarily
> visible via unrelated standard header files.

Indeed.  I had found that out, too, in the meantime, but forgot to CC: 
the list in the reply.

But that does mean there's already a cyclic header dependency now, 
introduced by <sys/reent.h> referencing to stuff from <string.h>, while 
<string.h> includes <sys/reent.h> (smae for <stdlib.h>).  That should 
really be avoided, if at all possible.  Usually, this would mean that 
the actual declarations/definitions of malloc() and memset() should be 
in separate header fragments, to be included by both <sys/reent.h> and 
<stdlib.h>/<string.h>, respectively.

Could this mean that many of the 274 occurences of #include <reent.h> in 
the *.c files could actually be dropped, since what those sources really 
need out of it is already provided indirectly by their includes of 
<stdio.h>, <string.h>, etc.?  In a small experimen the 4 files modified 
by this patch, and the Cygwin build of newlib, removing their #include 
<reent.h> didn't appear to break the build...



More information about the Newlib mailing list