I noticed that the win32 version of config.h defines __EXPORT as __declspec(dllexport). This is great for compiling the Common C++ library, but when trying to use/import the library in our own programs it causes the entire library to be re-exported from our programs too. The usual way of handling this seems to be with something like
This also makes it easy to figure out which classes belong in each of the 3 dlls. On win32, you really want to __IMPORT the ccxx and ccio classes when __EXPORTing the ccstd classes, and so on. This is pretty clear if you use CCXX_API or CCIO_API or whatnot.
-kevin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
#ifdef CCXX_EXPORTS // define in makefile or project
#define CCXX_API __EXPORT
#else
#define CCXX_API __IMPORT
#endif
config.h for default declare __EXPORT as __declspec(import). This is overwritten in export.h (included in all implementation, not headers).
I have changed export declaration with 4 macro:
CCXX_EXPORT()
CCXX_MEMBER()
CCXX_MEMBER_EXPORT()
CCXX_CLASS_EXPORT
(i will extend use for specify different linkage explicitly)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I noticed that the win32 version of config.h defines __EXPORT as __declspec(dllexport). This is great for compiling the Common C++ library, but when trying to use/import the library in our own programs it causes the entire library to be re-exported from our programs too. The usual way of handling this seems to be with something like
#ifdef CXX_EXPORTS
#define __EXPORT __declspec(dllexport)
#else
#define __EXPORT __declspec(dllimport)
#endif
and then CXX_EXPORTS is added to the project to build the library and omitted from projects that just import it.
I'm new to Common C++ and SourceForge, so any guidance on how things like this should be reported would be appreciated.
Thanks,
Gary
Hmm...let me think about this one...__EXPORT then isn't really a good name for this, since it can also be an "import", by default...
A typical msdev template would say something along the following:
#define __EXPORT __declspec(dllexport)
#define __IMPORT __declspec(dllimport)
// on unix, just declare empty __EXPORT and __IMPORT macros
// then do
#ifdef CCXX_EXPORTS // define in makefile or project
#define CCXX_API __EXPORT
#else
#define CCXX_API __IMPORT
#endif
#ifdef CCIO_EXPORTS
#define CCIO_API __EXPORT
#else
#define CCIO_API __IMPORT
#endif
// etc.
This also makes it easy to figure out which classes belong in each of the 3 dlls. On win32, you really want to __IMPORT the ccxx and ccio classes when __EXPORTing the ccstd classes, and so on. This is pretty clear if you use CCXX_API or CCIO_API or whatnot.
-kevin
Mm... there are no need to use code such
#ifdef CCXX_EXPORTS // define in makefile or project
#define CCXX_API __EXPORT
#else
#define CCXX_API __IMPORT
#endif
config.h for default declare __EXPORT as __declspec(import). This is overwritten in export.h (included in all implementation, not headers).
I have changed export declaration with 4 macro:
CCXX_EXPORT()
CCXX_MEMBER()
CCXX_MEMBER_EXPORT()
CCXX_CLASS_EXPORT
(i will extend use for specify different linkage explicitly)