KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'd like a simple example of exporting a function from a C++ Windows DLL. I'd like to see the header, the .cpp file, and the .def file (if absolutely required). I'd like the exported name to be undecorated . I'd like to use the most standard calling convention ( __stdcall ?). I'd like the use __declspec(dllexport) and not have to use a .def file. For example: //header extern "C" { __declspec(dllexport) int __stdcall foo(long bar); } //cpp int __stdcall foo(long bar) { return 0; } I'm trying to avoid the linker added underscores and/or numbers (byte counts?) to the name. I'm OK with not supporting dllimport and dllexport using the same header. I don't want any information about exporting C++ class methods, just c-style global functions. UPDATE Not including the calling convention (and using extern "C" ) gives me the export names as I like, but what does that mean? Is whatever default calling convention I'm getting what pinvoke (.NET), declare (vb6), and GetProcAddress would expect? (I guess for GetProcAddress it would depend on the function pointer the caller created). I want this DLL to be used without a header file, so I don't really need the a lot of the fancy #defines to make the header usable by a caller. I'm OK with an answer being that I have to use a *.def file.
Tags (comma-separated)
Save Edits
Cancel