From 94fe5c834904c1c2c1dfbe9e29cd5efbc7f5b284 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 21 Feb 2019 17:40:30 -0600 Subject: [PATCH] include/poll.h: Remove un-named union from 'struct pollfd'. It is not required by OpenGroup.org and violates the NuttX C coding standard because it is not C89 compatible. --- include/nuttx/compiler.h | 4 ++++ include/poll.h | 20 ++++++-------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index 6b749e9ed1a..c40e3b5cfe7 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -269,6 +269,10 @@ /* ISO C11 supports anonymous (unnamed) structures and unions, added in * GCC 4.6 (but might be suppressed with -std= option) + * + * CAREFUL: This can cause issues for shared data structures shared between + * C and C++ if the two versions do not support the same features. Structures + * and unions can lose binary compatibility! */ # undef CONFIG_HAVE_ANONYMOUS_STRUCT diff --git a/include/poll.h b/include/poll.h index b8152162270..aa23550314b 100644 --- a/include/poll.h +++ b/include/poll.h @@ -114,24 +114,16 @@ typedef uint8_t pollevent_t; struct pollfd { - /* REVISIT: Un-named unions are forbidden by the coding standard because - * they are not available in C89. - */ + /* Standard field */ -#ifdef CONFIG_HAVE_ANONYMOUS_UNION - union - { - int fd; /* The descriptor being polled */ - FAR void *ptr; /* The psock or file being polled */ - }; -#else int fd; /* The descriptor being polled */ - FAR void *ptr; /* The psock or file being polled */ -#endif - - FAR sem_t *sem; /* Pointer to semaphore used to post output event */ pollevent_t events; /* The input event flags */ pollevent_t revents; /* The output event flags */ + + /* Non-standard fields used internally by NuttX */ + + FAR void *ptr; /* The psock or file being polled */ + FAR sem_t *sem; /* Pointer to semaphore used to post output event */ FAR void *priv; /* For use by drivers */ };