Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Can';在VC++;除main外,获取链接错误_C++_Visual Studio 2008_Visual C++_Linker_Nasm - Fatal编程技术网

C++ Can';在VC++;除main外,获取链接错误

C++ Can';在VC++;除main外,获取链接错误,c++,visual-studio-2008,visual-c++,linker,nasm,C++,Visual Studio 2008,Visual C++,Linker,Nasm,谁能告诉我为什么我不能从NASM调用任何全局函数,除了main?(在你提问之前)是的,我已经在stackoverflow和internet上阅读了大约8个小时有关这方面的所有问题 C++代码。 void main(); extern "C" void nasm_function(void); void c_function() { } void main() { nasm_function(); system("pause"); } NASM代码, extern _c_

谁能告诉我为什么我不能从NASM调用任何全局函数,除了main?(在你提问之前)是的,我已经在stackoverflow和internet上阅读了大约8个小时有关这方面的所有问题

C++代码。

void main();

extern "C" void nasm_function(void);

void c_function()
{
}

void main()
{
    nasm_function();

    system("pause");
}
NASM代码,

extern _c_function
extern _main

segment .text

global _nasm_function
_nasm_function:
call _main  
call _c_function
building nasm using custom-build-rules with nasm.exe -f win32 
Calling convention is __cdecl (/Gd)
Visual Studio 2008
NASM version 2.05
Didn't include my_asm.obj as a input to linker
输出,

extern _c_function
extern _main

segment .text

global _nasm_function
_nasm_function:
call _main  
call _c_function
building nasm using custom-build-rules with nasm.exe -f win32 
Calling convention is __cdecl (/Gd)
Visual Studio 2008
NASM version 2.05
Didn't include my_asm.obj as a input to linker
1> 链接。。。1> my_asm.obj:错误LNK2001:未解析的外部符号 _c_函数1>F:\Projects\OSDev\assmebly_test\Debug\project.exe:致命错误LNK1120:1未解析的外部

正如您所看到的,我们没有得到main的链接错误。我不知道为什么。:)

设置,

extern _c_function
extern _main

segment .text

global _nasm_function
_nasm_function:
call _main  
call _c_function
building nasm using custom-build-rules with nasm.exe -f win32 
Calling convention is __cdecl (/Gd)
Visual Studio 2008
NASM version 2.05
Didn't include my_asm.obj as a input to linker

谁能告诉我是什么问题?提前谢谢。(请注意,这是一个示例程序,但仍然存在问题)

问题是名称混乱。解决方案是
extern“C”

“外部”C“void”C_函数(void);“这项工作?不:(呃…我真是个白痴。是的,它正在工作。非常感谢。如果有人仍然得到错误,我的错误是,我试图用不同于原始c函数的参数集来外部化函数