Paul Eggert wrote:
> If you're worried about other systems doing (d) you can run the attached 
> check-undef script to see whether it's possible there.

Thanks a lot. I did that on the include files of various systems, and
found this:

1) On Cygwin:
cygwin-2.9.0/usr/include/w32api/ws2tcpip.h:#define gai_strerror 
__MINGW_NAME_AW(gai_strerror)
cygwin-3.5.3/usr/include/w32api/ws2tcpip.h:#define gai_strerror 
__MINGW_NAME_AW(gai_strerror)
cygwin-2.9.0/usr/include/w32api/_mingw_unicode.h:# define __MINGW_NAME_AW(func) 
func##W
cygwin-2.9.0/usr/include/w32api/_mingw_unicode.h:# define __MINGW_NAME_AW(func) 
func##A

These macros expand to a single token; therefore this case is harmless.

2) These seem relevant:
msvc14/usr/include/WDBGEXTS.H:#define dprintf          
(ExtensionApis.lpOutputRoutine)
minix-3.3.0/usr/include/x86/mutex.h:#define     mtx_lock                        
u.s.mtxs_lock
netbsd-10.0/usr/include/x86/mutex.h:#define     mtx_lock                        
u.s.mtxs_lock

(for MSVC/clang and NetBSD).

3) Some others:
glibc-2.3.6/usr/include/tclPlatDecls.h:#define strncasecmp \
glibc-2.3.6/usr/include/tclPlatDecls.h:#define strcasecmp \
hpux-11.31/usr/include/sys/strenv.h:#define time            streams_time()
irix-6.5/usr/include/shlib.h:#define malloc     (* _libc_malloc)
irix-6.5/usr/include/shlib.h:#define free       (* _libc_free)
irix-6.5/usr/include/shlib.h:#define realloc (* _libc_realloc)

We can ignore these, as they are in very specialized include files.

> Simpler would 
> be checking that the argument of _GL_WARN_ON_USE is a single identifier 
> rather than some complicated expression, as this should prevent any 
> plausible problems arising from (d).
> 
> The attached proposed patches do that. The first patch does the real 
> work

I tested these invocations:

_GL_WARN_ID_LIKE (foo)
_GL_WARN_ID_LIKE (__)
_GL_WARN_ID_LIKE (77)
_GL_WARN_ID_LIKE (u.v.w)
_GL_WARN_ID_LIKE (u;v;w)
_GL_WARN_ID_LIKE (({ int a = c; a; }))

The last one produces a diagnostic, but unfortunately
  _GL_WARN_ID_LIKE (u.v.w)
  _GL_WARN_ID_LIKE (u;v;w)
don't give a warning or error.

> the second one is a near-copy of the patch I emailed earlier.

In summary, I think
  - The first patch is a brilliant idea, but since it does not catch some
    significant cases, I would not commit it.
  - The second patch is fine, except for 'dprintf' and 'mtx_lock'. For these
    two, it's better to keep the '#undef'.

Bruno




Reply via email to