Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You 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;
    }


Exactly, 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/li...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: