Correct way to export a DLL function on Mac OSX

流过昼夜 提交于 2019-12-23 03:35:14

问题


I'm trying to compile a simple DLL on a Mac OS X 10.6, and am confused about the proper way to declare a function that the DLL offers up for the world to use. Following sample code from a reliable source, I came up with:

__declspsec(dllexport) pascal int ReturnTheNumberFive(void)

but gcc barfs on it. What the sample code actually had was MACPASCAL and DLLExport, which I assumed were macros. I grepped through the sample codes, SDKs, etc for #defines and plugged in what I found. These definitions could have been buried inside #ifs, so what I found isn't good and true. Illogically, the compiler also barfs if I just do the obvious and use DLLExport and MACPASCAL, so that's no solution.

What is the correct way to make a DLL's function available to apps?


回答1:


By default, all symbols are visible in a .dylib. There are no calling convention changes (such as Pascal calling convention)

So, in short:

int ReturnTheNunmberFive(void) { return 6; }



来源:https://stackoverflow.com/questions/6838222/correct-way-to-export-a-dll-function-on-mac-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!