使用vc ++制作DLL的pblm [英] pblm in making dll using vc++
本文介绍了使用vc ++制作DLL的pblm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以告诉wats以下代码中的错误...
构建时,有很多错误......无法理解..
标题。 .dt1.h
can anyone tell wats the error in following code...
when building it ,lots of error are there...unable to understand ..
header ..dt1.h
展开 | 选择 | Wrap | 行号
推荐答案
发布你得到的错误,也是我我正在将这篇文章移到一个更合适的论坛。
Post the errors you are getting, also I am moving this post to a more appropriate forum.
你遇到的一个问题是dll是C的东西。在C函数中,名称必须是唯一的。它们在C ++中也必须是唯一的,但只要参数不同,C ++函数重载就会让你拥有许多相同名称的函数。因此,C ++编译器会将函数名称及其参数修饰(mangle)为一个唯一的名称,如PQAAX @ YZ。这将是dll中函数的名称。不好。
你需要使用externC在你的C ++代码中关闭mangler。你将失去C ++函数重载。
或者你可以保持C ++函数重载并使用DEF文件将受损的名称导出为其他东西。
这是一个Visual C ++示例。
创建一个dll项目。然后:
One problem you have is that a dll is a C thing. In C function names have to be unique. They have to be unique in C++ too but the C++ function overloading lets you have many functions of the same name so long as the arguments are different. Therefore, the C++ compiler will decorate (mangle) the function name and its arguments into a unique name like PQAAX@YZ. That will be the name of the function in the dll. Not good.
You need to use extern "C" in your C++ code to turn off the mangler. You will lose C++ function overloading.
Or you might keep C++ function overloading and export the mangled name as something else by using a DEF file.
Here is a Visual C++ example.
Create a dll project. Then:
展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号
得到的错误::
the errors which m getting::
展开 | 选择 | Wrap | 行号
这篇关于使用vc ++制作DLL的pblm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文