You don't need two headers. If you have only one public header you can also add the export/import macros to that header.
It is just customary to split the macro definition into a separate header, because a library often has more than one public header and then you can just include the macro definition one in each of them.
The import/export macro definition is required to get symbol visibility right. Depending on platform and compiler settings, symbols such as classes or functions can be "hidden" by the compiler, i.e. only visible within the library itself but not to the program linking the library.
Naturally you want the symbols of your public API to be visible, hence the need to mark them for export.
Since you mentioned static linking a couple of times: this has nothing to do with DLLs, a concept which has "Dynamic Linking" even as part of its name!
Cheers,
_





Reply With Quote

Bookmarks