【问题标题】:msvc linker error: error C2061: syntax error : identifiermsvc 链接器错误:错误 C2061:语法错误:标识符
【发布时间】:2022-06-17 00:07:11
【问题描述】:

我用 cl.exe /MT /c sqlhandler.cpp 将 cpp 代码编译为 .obj,我得到了 sqlhandler.obj 文件。

现在我想将它包含在我的 c 项目中并使用从 sqlhandler 导出的函数,我的 c 代码“main.h”,我声明了类似:extern bool ReadTable(const char* tableName);

我正在编译我的 c 项目。用这个命令行执行:cl.exe /nologo /Ox /MT /W0 /GS- /DNDEBUG /Tc *.c Sqlhandler.obj /link advapi32.lib user32.lib /SUBSYSTEM:CONSOLE /out:test.exe

我收到以下错误:main.h(109) : error C2061: syntax error : identifier 'ReadTable' error C2059: syntax error : 'type' error C2061: syntax error : identifier 'SqlHandler'

这是我在“main.h”中的声明:extern bool ReadTable(const char* tableName); extern bool SqlHandler(LPCWSTR stringPath);

dumpbin /symbols sqlhander.obj那些函数:

 0F9 00000000 SECT48 notype ()    External     | ?GetRowCount@@YAHXZ (int __cdecl GetRowCount(void))
0FA 00000000 SECT5A notype ()    External     | ?SqlHandleFree@@YAXXZ (void __cdecl SqlHandleFree(void))
0FB 00000000 SECT5C notype ()    External     | ?SqlHandler@@YA_NPEB_W@Z (bool __cdecl SqlHandler(wchar_t const *))
0FC 00000000 SECT56 notype ()    External     | ?ReadTable@@YA_NPEBD@Z (bool __cdecl ReadTable(char const *))

【问题讨论】:

  • 在标题中,将您的声明放在extern "C" { } 范围内。
  • @JonathanPotter 但那些 sqlhander.obj 是来自 cpp 文件的编译器

标签: c++ c windows visual-studio visual-c++


猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多