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 */ };