On 06 Oct 2022 06:43, Tsukasa OI wrote: > Clang generates a warning if there is a function declaration/definition > with zero arguments. Such declarations/definitions without a prototype (an > argument list) are deprecated forms of indefinite arguments > ("-Wdeprecated-non-prototype"). On the default configuration, it causes a > build failure (unless "--disable-werror" is specified). > > include/getopt.h defines some getopt function definitions but one of them > has a form "extern int getopt ();". If this form is selected in > include/getopt.h, Clang generates a warning and the build fails by default. > > In really old environments, this getopt definition with no arguments is > necessary (because the definition may change between environments). > However, this definition is now a cause of problems on modern environments. > > A good news is, this definition is not always selected (e.g. if used by > binutils/*.c). This is because configuration scripts of binutils, gas, > gprof and ld tries to find known definition of getopt function is used and > defines HAVE_DECL_GETOPT macro. If this macro is defined when getopt.h is > included, a good form of getopt is used and Clang won't generate warnings. > > This commit adds a modified portion of ld/configure.ac to find the known > getopt definition. If we could find one (and we *will* in most modern > environments), we don't need to rely on the deprecated definition. > --- > sim/config.h.in | 3 +++ > sim/configure | 32 ++++++++++++++++++++++++++++++++ > sim/configure.ac | 10 ++++++++++ this logic belongs in m4/sim_ac_platform.m4, not configure.ac should leave a comment above the code too indicating that this logic is purely for local getopt.h usage, and is copied from other dirs (e.g. the binutils files). -mike