https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118375
Bug ID: 118375 Summary: Fixits for feature test macros (FTMs) Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: sjames at gcc dot gnu.org CC: dmalcolm at gcc dot gnu.org Target Milestone: --- We don't currently include any hints for feature test macros (FTMs) but this came up quite a lot with the C99/GCC 14 porting work especially. For example, with this in C: ``` // no _GNU_SOURCE defined #include <errno.h> int main() { char* x = program_invocation_name; } ``` We get: ``` <source>:1:1: error: expected identifier or '(' before '/' token 1 | /#include <errno.h> | ^ <source>:1:2: error: stray '#' in program 1 | /#include <errno.h> | ^ Compiler returned: 1 ``` We could emit fixits for these. Note that this is rarely an issue for C++ (see PR11196 and so on). (See also PR115735 where we've discussed scraping some information out of glibc docs.) (dave, I've cc'd you on this for completeness but it hasn't come up in this cycle and it *tends* to be more of an issue with either older glibc or musl, as we've moved towards including more in _DEFAULT_SOURCE for glibc in recent years to avoid people getting this wrong.)