Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix a compilation error on GCC/Linux
xstrdup.c:13:18: warning: implicit declaration of function ‘strdup’; did you mean ‘xstrdup’? [-Wimplicit-function-declaration] 13 | char *copy = strdup(str); | ^~~~~~ | xstrdup As Stack Overflow says: > It allows you to use functions that are not part of the standard C > library but are part of the POSIX.1 (IEEE Standard 1003.1) standard. > Using the macros described in feature_test_macros allows you to > control the definitions exposed by the system header files. > > As far as I know _POSIX_SOURCE is obsolete and you should use > _POSIX_C_SOURCE instead. > > For example, if you want to use strndup, you have to use > > #define _POSIX_C_SOURCE 200809L https://stackoverflow.com/a/48332467/2103996 And the libc manual: > Macro: _POSIX_C_SOURCE > > Define this macro to a positive integer to control which POSIX > functionality is made available. The greater the value of this macro, > the more functionality is made available. > > If you define this macro to a value greater than or equal to 1, then > the functionality from the 1990 edition of the POSIX.1 standard (IEEE > Standard 1003.1-1990) is made available. > > If you define this macro to a value greater than or equal to 2, then > the functionality from the 1992 edition of the POSIX.2 standard (IEEE > Standard 1003.2-1992) is made available. > > If you define this macro to a value greater than or equal to 199309L, > then the functionality from the 1993 edition of the POSIX.1b standard > (IEEE Standard 1003.1b-1993) is made available. > > If you define this macro to a value greater than or equal to 199506L, > then the functionality from the 1995 edition of the POSIX.1c standard > (IEEE Standard 1003.1c-1995) is made available. > > If you define this macro to a value greater than or equal to 200112L, > then the functionality from the 2001 edition of the POSIX standard > (IEEE Standard 1003.1-2001) is made available. > > If you define this macro to a value greater than or equal to 200809L, > then the functionality from the 2008 edition of the POSIX standard > (IEEE Standard 1003.1-2008) is made available. https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
- Loading branch information