Add some temporary code to preprocess with gcc -E
This commit is contained in:
parent
19c61a91fe
commit
a87b938234
30
src/main.c
30
src/main.c
@ -1,8 +1,36 @@
|
||||
#include <stdio.h>
|
||||
#include "parser.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
void preprocess(const char * input_fname)
|
||||
{
|
||||
char fname[] = "/tmp/cxlppXXXXXX";
|
||||
int fd = mkstemp(fname);
|
||||
pid_t pid = fork();
|
||||
if (pid < 0)
|
||||
{
|
||||
perror("fork");
|
||||
}
|
||||
else if (pid == 0)
|
||||
{
|
||||
dup2(fd, STDOUT_FILENO);
|
||||
close(fd);
|
||||
execlp("gcc", "gcc", "-x", "c", "-E", input_fname, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
close(fd);
|
||||
waitpid(pid, NULL, 0);
|
||||
unlink(fname);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
printf("coming soon...\n");
|
||||
preprocess(argv[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user