cctools for MacOS 10.14 (at least) unconditionally uses the __has_include preprocessor directive (i.e. without checking if defined __has_include as normally suggested for portable code). So we need to handle it a little bit. For now we simply say "nope" aka evaluate to 0.
Unified · Split
| @@ -1450,6 +1450,7 @@ static int expr_preprocess(void) · 1449 unmodified lines | |||
| 1450 | pp_expr = 1; | 1450 | pp_expr = 1; |
| 1451 | while (tok != TOK_LINEFEED && tok != TOK_EOF) { | 1451 | while (tok != TOK_LINEFEED && tok != TOK_EOF) { |
| 1452 | next(); /* do macro subst */ | 1452 | next(); /* do macro subst */ |
| 1453 | redo: | ||
| 1453 | if (tok == TOK_DEFINED) { | 1454 | if (tok == TOK_DEFINED) { |
| 1454 | next_nomacro(); | 1455 | next_nomacro(); |
| 1455 | t = tok; | 1456 | t = tok; |
| @@ -1467,10 +1468,26 @@ static int expr_preprocess(void) · 11 unmodified lines | |||
| 1467 | } | 1468 | } |
| 1468 | tok = TOK_CINT; | 1469 | tok = TOK_CINT; |
| 1469 | tokc.i = c; | 1470 | tokc.i = c; |
| 1471 | } else if (1 && tok == TOK___HAS_INCLUDE) { | ||
| 1472 | next(); /* XXX check if correct to use expansion */ | ||
| 1473 | skip('('); | ||
| 1474 | while (tok != ')' && tok != TOK_EOF) | ||
| 1475 | next(); | ||
| 1476 | if (tok != ')') | ||
| 1477 | expect("')'"); | ||
| 1478 | tok = TOK_CINT; | ||
| 1479 | tokc.i = 0; | ||
| 1470 | } else if (tok >= TOK_IDENT) { | 1480 | } else if (tok >= TOK_IDENT) { |
| 1471 | /* if undefined macro */ | 1481 | /* if undefined macro, replace with zero, check for func-like */ |
| 1482 | t = tok; | ||
| 1472 | tok = TOK_CINT; | 1483 | tok = TOK_CINT; |
| 1473 | tokc.i = 0; | 1484 | tokc.i = 0; |
| 1485 | tok_str_add_tok(str); | ||
| 1486 | next(); | ||
| 1487 | if (tok == '(') | ||
| 1488 | tcc_error("function-like macro '%s' is not defined", | ||
| 1489 | get_tok_str(t, NULL)); | ||
| 1490 | goto redo; | ||
| 1474 | } | 1491 | } |
| 1475 | tok_str_add_tok(str); | 1492 | tok_str_add_tok(str); |
| 1476 | } | 1493 | } |
| @@ -91,6 +91,7 @@ · 90 unmodified lines | |||
| 91 | DEF(TOK___FUNCTION__, "__FUNCTION__") | 91 | DEF(TOK___FUNCTION__, "__FUNCTION__") |
| 92 | DEF(TOK___VA_ARGS__, "__VA_ARGS__") | 92 | DEF(TOK___VA_ARGS__, "__VA_ARGS__") |
| 93 | DEF(TOK___COUNTER__, "__COUNTER__") | 93 | DEF(TOK___COUNTER__, "__COUNTER__") |
| 94 | DEF(TOK___HAS_INCLUDE, "__has_include") | ||
| 94 | 95 | ||
| 95 | /* special identifiers */ | 96 | /* special identifiers */ |
| 96 | DEF(TOK___FUNC__, "__func__") | 97 | DEF(TOK___FUNC__, "__func__") |