Fix coredump on linux when boostrapping tcc with -std=c11

This commit is contained in:
Christian Jullien 2020-06-26 11:36:41 +02:00
parent 03646ad46f
commit 6a15f15093

View File

@ -105,6 +105,15 @@ void parse_args(TCCState *s)
else if (a[1] == 'L') else if (a[1] == 'L')
tcc_add_library_path(s, a+2); tcc_add_library_path(s, a+2);
else if (a[1] == 'D') { else if (a[1] == 'D') {
#if defined(__linux__) \
&& defined(__STDC_VERSION__) \
&& (__STDC_VERSION__ >= 201112L)
/*
* gcc -std=c11 no longer declare strdup which fails with
* coredump (at least on Linux x64).
*/
extern char* strdup(const char*);
#endif
char *dup = strdup(a); char *dup = strdup(a);
char *eq = strchr(dup+2, '='); char *eq = strchr(dup+2, '=');
if (eq) { if (eq) {