c - 使用c创建h文件

标签 c header cfile hfile

我有一个定义了 typedef 结构的源文件:

typedef struct {
    unsigned int seed;
} generator;

generator *create() {
    generator *g = (generator*)malloc(sizeof(generator));
    g->seed = time(0);
    
    return g;
}

void set_seed(generator *g, unsigned int s) {
    g->seed = s;
}

unsigned int rand_int(generator *g) {
    return g->seed = (a * g->seed) % m;
} 

我需要编写头文件,.h文件。但我不断得到

Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64

为了避免此错误,请帮助我编写 .h 文件。

最佳答案

将此代码片段添加到您的代码中:

int main(void) {}

您的程序中缺少main函数。

关于c - 使用c创建h文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54843946/

相关文章:

c - 包括外部声明的枚举在内的问题 - C 代码

file - CFile 和 CStdioFile 在写入和读取时产生不同的结果

c++ - recv()/send()(在 Socket 中)或 read()/write()(在 CFile 中)错误

c++ - 长文件 (15 MB) 上的 CStdioFile::GetPosition 有几个字节错误

c++ - 如何在C中使用VB库?

c - 通用加成合成程序

C - 引号和撇号之间的区别( "vs ')

c - 在不按 "enter"的情况下获取 c 中的字符

php - 重定向到同一页面后如何调用jquery函数?

c# - 使用 System.Net.WebRequest 时无法设置某些 HTTP header