https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114870

            Bug ID: 114870
           Summary: stddef.h problem with -Wsystem-headers on Fedora 40
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eggert at cs dot ucla.edu
  Target Milestone: ---

Created attachment 58049
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58049&action=edit
fix stddef.h to survive multiple includes, some with __need_size_t etc.

I found this when trying to build GNU diffutils on Fedora 40. This is gcc (GCC)
14.0.1 20240411 (Red Hat 14.0.1-0) on x86-64. Compile the following two-line
program t.c with 'gcc -std=gnu23  -Wsystem-headers -E t.c >t.i':

  #include <stddef.h>
  #include <time.h>

GCC issues the following diagnostics:

  In file included from /usr/include/time.h:29,
                   from t.c:2:
  /usr/lib/gcc/x86_64-redhat-linux/14/include/stddef.h:457:9: warning:
"__STDC_VERSION_STDDEF_H__" redefined
    457 | #define __STDC_VERSION_STDDEF_H__       202311L
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from t.c:1:
  /usr/lib/gcc/x86_64-redhat-linux/14/include/stddef.h:457:9: note: this is the
location of the previous definition
    457 | #define __STDC_VERSION_STDDEF_H__       202311L
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~

It seems that <stddef.h> is not properly protected against multiple includes,
some with __need_size_t and __need_NULL and some without.

The attached patch to stddef.h worked around the problem for me.

Reply via email to