4 ms·
Really wish gcc had a -std flag for "POSIX but no GNU extensions". Currently you're forced to choose between -std=cXX for the pure C standard or -std=gnuXX for
by PhilipRoman 4y ago
Really wish gcc had a -std flag for "POSIX but no GNU extensions". Currently you're forced to choose between -std=cXX for the pure C standard or -std=gnuXX for C + POSIX + GNU extensions.
- JoshTriplett 4y agoYou can use POSIX functions in -std=c17 or similar. For instance: #define _POSIX_C_SOURCE 200809L #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char *x = strdup("hello world"); printf("%s\n", x); free(x); return 0; }
- account42 3y agoExactly, these are libray extensions so they are controlled via defines and not (directly) via compiler flags. Which ones there are (and what they do) depend on the standard C library and not the compiler. For glibc: https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_node/libc_13.html https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_node/li...