Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

braves

__declspec(dllexport)

This topic is 6593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
__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

Share this post


Link to post
Share on other sites
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





Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!