I'm writing a C++ library using MinGW (4.8.0 dw2 posix). This library is used in another C++ project that use another compiler( in this case msvc ).
Refering to this I was redesign my C++ library. There are two things that I don't know how can I do:
- Can I use namespaces?
- I noticed that time_t on MinGW is 32 bit and in msvc is 64 bit. What Can I do?
1)
Does this broke the ABI:
// Window.h
// MYLIB_API defined as __declspec( dllexports )
// MYLIB_CALL defined as __stdcall
namespace mylib {
class Window {
public:
virtual void MYLIB_CALL destroy() = 0;
virtual void MYLIB_CALL setTitle(const char* title) = 0;
virtual const char* MYLIB_CALL getTitle() = 0;
void operator delete(void* p) {
if (p) {
Window* w = static_cast<Window*>(p);
w->destroy();
}
}
};
} // mylib
extern "C" MYLIB_API mylib::Window* MYLIB_CALL CreateWindow(const char* title);
2
How can I be sure that foundamental types are the same accross different compiler. For example in this case time_t
is defined as unsigned long
on MinGW and `__int64' on msvc. What can I do?