This does not really have anything to do with the compiler. POSIX specifies utilities, interfaces and the accompanying header files - the compiler is only concerned with the specifics of the programming language.

That said, if the header file set that you are using is well-implemented you should be able to enable/disable the feature sets that you are using with proper -D and -U options for gcc.

For example including fcntl.h will not allow access to fallocate() unless _GNU_SOURCE has been defined. With the same header, you need to define _POSIX_C_SOURCE to 200809L or greater for the F_DUPFD_CLOEXECfcntl() to be available.