例如:
file1.c
有:
static const struct
{
int a;
int b;
int c;
} mystruct = { 1, 2, 3};
file2.c
有:
#include <stdio.h>
#include "file1.c"
等等。
这样做可以吗?
最佳答案
Is this ok to do? Please let me know. Thanks.
这在技术上可行,但我不推荐这样做。相反,我会建议将您的声明放在头文件中,然后将两个 .c 文件都包含在您的项目/makefile/etc 中。
这将更像是一种“标准”工作方式,进而使您的项目更易于维护。
关于c - 可以在另一个 .c 文件中包含一个 .c 文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11849868/