Advertisement

__declspec(dllexport)

Started by September 01, 2000 12:11 PM
2 comments, last by braves 24 years, 3 months ago
Hello everyone, I was reading some code in a book and I seen __declspec(dllexport), what does this and all the __declspec() functions(not sure if this is a function or what?) do? I have also seen other __declspec like __declspec(noreturn) and __declspec(thread)but I don''t have any help files to look these things up so if someone can help please do. Thank you in advance. Braves
__declspec is a compiler specific extension in this case to a type. Think of it kind of like #pragma.

dllexport is used to mark the funtion to be exported from a dll. It doesn''t work very well due to the naming rules IMHO. Best to just stick with .def files.

noreturn is used to tell the compiler that this function isn''t supposed to ever return and that it shouldn''t complain. You see it a lot on error reporting code that eventually calls exit() or ExitProcess() but for some reason isn''t declared as void.

thread is used to mark some data as having a seperate instance for each thread.

-Mike
Advertisement
Ok, thanks...I understand now. You also only use __declspec(dllexport) when calling explicit *.dll files and not with implicit *.dll''s, right? Also the declspec is used rather than making a *.def file. Another question I have is, how do you make the choice if it''s best to use the implicit or explicit *.dll files? I have seen this #pragma flag alot but not sure what those are either? I think they are some type of compiler flag but I am not sure? You also said dllexport don''t work well with due to naming rules like IMHO. What is IMHO?
Thanks,
Braves





IMHO is the standard Internet acronym for In My Humble Opinion.

dllexport has nothing to do with how you use your dll''s. It''s intended solely as a way to replace the .def file. As far as naming, if you use dllexport you may not get what you expect. e.g. __declspec(dllexport) void Foo(int x) might get exported with the name "_Foo@4" instead of just "Foo". If you''re using C++ you''ll get the fully mangled, impossible to figure out version. If you use a def file you can name the export whatever you want, exactly how you want it.

There are lots of pragma''s. The docs that came with your compiler should talk about them.

This topic is closed to new replies.

Advertisement