.h文件应该是与外部函数的接口;如何在包含标头的.cc文件中进行定义
.h file supposed to be interface with extern functions; how to define in .cc file that includes the header?
我的头文件1t.h中有一个函数,如下所示:
extern int dthreads_libinit(dthreads_func_t func, void *arg);
然后我想在一个单独的文件中实现这个功能,其中包括1t.h:
int dthreads_libinit(dthreads_funct_t func, void* arg) {
//Do something here...
}
我得到这些错误虽然:
‘int dthreads_libinit’ redeclared as different kind of symbol'
error: previous declaration of ‘int dthreads_libinit(dthreads_func_t, void*)
我做的事情出了什么问题?
函数定义的签名中有一个拼写错误
dthreads_libinit(dthreads_funct_t func, void* arg) {
// ^
如果您将此更正为
dthreads_libinit(dthreads_func_t func, void* arg) {
因为它用于函数声明中的func
参数
extern int dthreads_libinit(dthreads_func_t func, void *arg);
代码编译良好(无论使用g++
还是gcc
)。
相关文章:
- 如何使用CMake编译.proto文件来生成.grpcp.pb.cc和.grpc.pb.h文件
- 编译要在英特尔Hyperscan中使用的.cc文件时出现问题
- 使用 g++ 编译时列出所有 cpp/cc 文件是否正常?
- 在头文件和 .cc 文件之间建立关系
- 如何在makefile中添加.c,.cc和.so文件以创建另一个.so
- 如何访问其他 .cc 文件中命名空间中定义的函数
- 如果需要测试,则C 将常数变量放在CC文件中
- 连接两个C 文件(list.cc and queue.cc)困难
- main.cc:5:30:致命错误:文件夹/file.h:没有这样的文件或目录
- 我如何确保修改.H文件时,使用Visual Studio 2008将包括其在内的.cc文件自动编译
- 我可以在生成文件中为 CC、CFLAGS 使用其他名称,或者将它们硬连接到 GNU make 中
- 如何在 Omnet++ INET 的示例中找到实现 .cc 文件
- .h文件应该是与外部函数的接口;如何在包含标头的.cc文件中进行定义
- 我可以在客户端使用 .cc 原型文件并在服务器端使用 .java proto 文件吗?
- 类成员C++标头和 .cc 文件问题
- 在头文件中声明要由 .cc 文件访问和填充的结构
- .cc和.cpp文件后缀有什么区别
- dsr/linkcache.cc:致命错误:list.h:没有这样的文件或目录
- 当项目导入到eclipse中时,.cpp文件被转换为.cc文件
- 把控制发回主站.Cc文件在我的c++项目从另一个源文件