I have this code that just won't compile on VC++, so what I'm going to do is generate a DLL with MinGW and use at run time by passing a generic pointer to a structure which both compilation units will be aware of:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
//header.h
struct Type {/*...*/};
//VC++.cpp
#include "header.h"
//...
Type s;
DLL.call("indirect",&s);
//MinGW.cpp
#include "header.h"
//...
extern"C"void indirect(void *p){
f(p);
}
void f(void *p){
Type *s=(Type *)p;
}
So, what I need to know is, will both compilers generate compatible types? The code in Type is not a problem, since I'll probably duplicate it in the DLL. The problem is the data.
If "Type" is simple (no inheritance, no virtual functions, etc.) then two different compilers for the same machine (same word size) should generate compatible types. Still, it would be better to use the appropriate compiler extensions to make sure that the alignment is the same in both cases.
It uses FFmpeg. The problem isn't really that it doesn't compile. It's that it doesn't link. http://ffmpeg.arrozcru.org/wiki/index.php?title=Static_LIB_MSVC
It's just a nightmare. When I finally get it to link, it crashes instantly, so I prefer to use MinGW. Sure, I have no debugger and I have to manually link it to the rest of the code, but hey, at least it works.