If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

A question regarding dllexport and dllimport

I understand that the files using the exported class or function need to call this class or function with dllimport and the file containing the exported class or function needs to call this class or function with dllexport. But I tried to use __declspec(dllexport) only instead of the statements above. It still works. Is there anything I am missing?Why'd we have to switch between dllexport and dllimport? Thanks.

Re: A question regarding dllexport and dllimport

In the project that exports something, you must marked the exported symbols (such as functions or types) with __declspec(dllexport). However, in the project where you import them, you must mark them with __declspec(dllimport). The code above is a little trick to have a single declaration of these symbols. By defining DLLMICRO in your exporting project, you make sure these symbols are compiled with the __declspec(dllexport) markup, while in the importing project where DLLMICRO should not be defined, they would end up marked with __declspec(dllimport).

Re: A question regarding dllexport and dllimport

In my last post, I tried to explain that if I use dllexport only without using a macro to switch between dllexport and dllimport, my app still works. In other words, I don't see why I need dllimport. What problems will I have without dllimport? Thanks.

Re: A question regarding dllexport and dllimport

Originally Posted by LarryChen

I tried to explain that if I use dllexport only without using a macro to switch between dllexport and dllimport, my app still works.

You tried. But nobody still understands what "I use", "switch between dllexport and dllimport", "app works" really mean. Without seeing how you "use", "switch" and test "app working" nobody would help you with your question.

I believe, cilu has fully answered your question, and now the question is whether you comprehend the answer.

Re: A question regarding dllexport and dllimport

Generally, the sentence "the program works" doesn't prove anything. In most cases, this means: "program crashes once per month and this crash cannot be reproduced" or "program works on my computer, but crashes on another computer/Windows version".

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.