Thanks.
This is a great example of an idiom that will not be broken by the C2x change to treat char shm_open()
as if it was char shm_open(void)
, but would be broken by -Werror=strict-prototypes
.
Since autoconf goes out of its way to avoid seeing any other incompatible prototypes, the (void) interpretation is perfectly fine for it. So, if we make Clang emit a warning (with default-Werror) only for subsequent uses which are incompatible with the interpretation of this declaration as a zero-arg prototyped function (as I’d suggested above), this should be OK.
The test code generated from the above autoconf snippet is:
/* confdefs.h */
#define PACKAGE_NAME "foo"
#define PACKAGE_TARNAME "foo"
#define PACKAGE_VERSION "1.0"
#define PACKAGE_STRING "foo 1.0"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
/* end confdefs.h. */
/* Define shm_open to an innocuous variant, in case <limits.h> declares shm_open.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define shm_open innocuous_shm_open
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char shm_open (); below. */
#include <limits.h>
#undef shm_open
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char shm_open ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_shm_open || defined __stub___shm_open
choke me
#endif
int
main (void)
{
return shm_open ();
;
return 0;
}