What does it mean exactly when I define a class this way in C++ project:
class THIS_DLL_NAME class_name{
…
}
thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As Basile and Hans stated in the comments above, THIS_DLL_NAME will be a macro that conditionally expands depending on whether you are building the library itself, or code that just uses that library.
(BTW, I’m assuming you’re on Windows here, due to the DLL terminology.)
THIS_DLL_NAMEcan expand to either__declspec(dllexport)or__declspec(dllimport). When the header file is included in the .cpp files that you’re compiling into THIS_DLL.dll, the compiler needs to see__declspec(dllexport)in order to generate the proper entry points to export them from the DLL.When your class header is included in code that is using THIS_DLL.dll, the compiler needs to see
__declspec(dllimport)in order to generate the right code to import the symbol (and resolve it at runtime).You can read up on more of the details straight from Microsoft in this article – Importing and Exporting (MSDN).