Compiling multiple C files in a program

前端 未结 4 1916
你的背包
你的背包 2020-12-05 08:32

I have the following two files:

file1.c

int main(){
  foo();
  return 0;
}

file2.c



        
4条回答
  •  渐次进展
    2020-12-05 08:38

    It's ugly, but using gcc, you could:

    gcc -include file2.c file1.c
    

    -include is a flag to the preprocessor which will include the contents of file2.c at the very top of file1.c. Having said that, it's a poor choice, and breaks down for all but the simplest of programs.

提交回复
热议问题