diff --git a/cc.c b/cc.c index d3ca6fd..8db16e6 100644 --- a/cc.c +++ b/cc.c @@ -46,7 +46,7 @@ int main(int argc, char** argv, char** envp) int debug_flag = TRUE; FILE* in = stdin; FILE* tempfile; - char* destination_name = "/dev/stdout"; + char* destination_name = "a.out"; FILE* destination_file = stdout; init_macro_env("__M2__", "42", "__INTERNAL_M2__", 0); /* Setup __M2__ */ char* name; @@ -174,11 +174,7 @@ int main(int argc, char** argv, char** envp) { fputs("\n/* Preprocessed source */\n", destination_file); output_tokens(global_token, destination_file); - - if (destination_file != stdout) - { - fclose(destination_file); - } + fclose(destination_file); } else { diff --git a/cc_macro.c b/cc_macro.c index 2df09cf..3cdf397 100644 --- a/cc_macro.c +++ b/cc_macro.c @@ -653,17 +653,32 @@ void macro_directive() { handle_error(); } + else if(match("#include", macro_token->s)) + { + eat_current_token(); + if(match("<", macro_token->s)) + { + eat_current_token(); + if(match("stdio", macro_token->s)) + { + eat_current_token(); + STDIO_USED = TRUE; + } + eat_current_token(); + eat_current_token(); + eat_current_token(); + } + else + eat_current_token(); + } else { - if(!match("#include", macro_token->s)) - { - /* Put a big fat warning but see if we can just ignore */ - fputs(">>WARNING<<\n>>WARNING<<\n", stderr); - line_error_token(macro_token); - fputs("feature: ", stderr); - fputs(macro_token->s, stderr); - fputs(" unsupported in M2-Planet\nIgnoring line, may result in bugs\n>>WARNING<<\n>>WARNING<<\n\n", stderr); - } + /* Put a big fat warning but see if we can just ignore */ + fputs(">>WARNING<<\n>>WARNING<<\n", stderr); + line_error_token(macro_token); + fputs("feature: ", stderr); + fputs(macro_token->s, stderr); + fputs(" unsupported in M2-Planet\nIgnoring line, may result in bugs\n>>WARNING<<\n>>WARNING<<\n\n", stderr); /* unhandled macro directive; let's eat until a newline; om nom nom */ while(TRUE)