What the symbol between class and class name mean?

Dear all:

I have a basic question related to the class definition.

I usually see something like

class VTK_COMMON_EXPORT vtkClass

in the software package. And the middle is defined as

#define VTK_COMMON_EXPORT

So what does VTK_COMMON_EXPORT do please? And why it is defined as nothing.

Also, I see something defined as:

#define VTK_TK_EXPORT VTK_ABI_EXPORT

Does it mean the value of VTK_TK_EXPORT is the same as VTK_ABI_EXPORT?

How does class benefit from such a definition please?

Thanks
So what does VTK_COMMON_EXPORT do please?

It doesn't mean anything here because it has no value.


#define VTK_TK_EXPORT VTK_ABI_EXPORT
Does it mean the value of VTK_TK_EXPORT is the same as VTK_ABI_EXPORT?

Yes.
Then why VTK_COMMON_EXPORT appears between the class and class name?

Can it have any value if it appears there?

Thanks
Such symbols are typically defined when creating libraries.

When compiling the library, the symbol will have a value needed to make the object exportable (visible to outside modules). For example, on Windows, a DLL has a table of functions that external programs can use. The DLL probably has a host of other functions only it uses. By having the compiler/platform-specific symbol there it gets listed in the DLL's export table.

When using the library, the symbol only needs the usual import status; declaring it with the export status would confuse the compiler because you don't define the functions -- you only want to use them.

Hence, the easy way is to #define a name such as VTK_TK_EXPORT that you can manipulate during the compilation process to build or link things the proper way.

If that makes no sense (yet), don't fret it. You only need to care if you are creating your own library.

Hope this helps.
Thanks, It makes some sense to me. Does it mean when compile the class with the symbol, it will generate a value and will be listed in the dll export table? In this case, does it mean a static library will never have such a thing? Also, without the symbol, it still can be compiled into a dll, cannot it? Then what's the benefit of using this symbol please?
Any answers please?
I explained the benefit - it is necessary to make the function available to users of the DLL. Beyond that, it doesn't matter.

To learn more you'll have to study on your own, as I don't have interest in explaining all the gory technical details for one particular system here and now. (Sorry.) Google around "msdn dll" for more.
Topic archived. No new replies allowed.