提交 02fea2f3 编写于 作者: Z Zihao Yu

tools,gen-expr: generate intermediate files under /tmp

上级 4f4136df
......@@ -5,4 +5,4 @@ $(APP): gen-expr.c
.PHONY: clean
clean:
-rm $(APP) .code.c .expr 2> /dev/null
-rm $(APP) 2> /dev/null
......@@ -97,12 +97,15 @@ int main(int argc, char *argv[]) {
sprintf(code_buf, code_format, buf);
FILE *fp = fopen(".code.c", "w");
FILE *fp = fopen("/tmp/.code.c", "w");
assert(fp != NULL);
fputs(code_buf, fp);
fclose(fp);
fp = popen("gcc .code.c -Wall -Werror -o .expr && ./.expr", "r");
int ret = system("gcc /tmp/.code.c -o /tmp/.expr");
if (ret != 0) continue;
fp = popen("/tmp/.expr", "r");
assert(fp != NULL);
int result;
fscanf(fp, "%d", &result);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册