HI All.
Im new in c++. some wher i saw the code
-
#define DECLAREDLL
-
-
class DECLAREDLL myclass
-
{
-
};
-
why DECLAREDLL before class name?
can any body solve my doubt?
THANK U.
I am also new to c/c++, but have worked with a couple of instances where you need to define the file. Usually you will use:
- #ifndefine DECLAREDLL
-
#define DECLAREDLL
As someone said in this post, you define DECLAREDLL if DECLAREDLL is not defined. What this does, if this file is not loaded in memory, the compiler will do so. If there is an instance where this file is loaded in memory, the compiler will access the file that has been loaded instead of loading the code again. (At least that's how it has been told to me.
Another use can be when you create DLLs.
- #ifdef DECLAREDLL
-
#define DECLAREDLL_DLL __export __cdecl
-
#else
-
#define DECLAREDLL_DLL __import __cdecl
-
#endif
which basically states that if DECLAREDLL is define (see above), insert __export __cdecl where DECLAREDLL_DLL typed, otherwise, use __import __cdecl.
Hope that make sense.
Good luck.