-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure STDCALL/STDCALLPTR is only invoked on x86 #72
Conversation
8c78689
to
21d486a
Compare
Why just not remove STDCALLs entirely? Is there low-level magic that may prevent it runs in 32bit mode? |
@winterheart x86 calls had several different forms and without specifying how an exposed library function should be structured your compiler may end up structuring or calling that library function incorrectly. |
fbd3f1c
to
bfc3c1d
Compare
@winterheart |
I'll let others review this one, I'm not very comfortable with x86/win32 subjects :) |
I'd suggest move 32-bitness check into configuration level to CMakeLists.txt with (place it after project(...)):
And to code goes (lib/module.h or into libraries itself): #ifdef D3_ENABLE_STDCALLS
#ifdef _MSC_VER // Visual C++ Build
#define STDCALL __stdcall
#define STDCALLPTR *STDCALL
#else // Non-Visual C++ Build
#define STDCALL __attribute__((stdcall))
#define STDCALLPTR STDCALL *
#endif // Visual C++ Build
#else // D3_ENABLE_STDCALLS
#define STDCALL
#define STDCALLPTR STDCALL *
#endif // D3_ENABLE_STDCALLS And this code will be activated only on 32-bit systems and depends on compiler. Still, I don't know why this still needed on 32-bit Linux systems, but for compatibility I would left it as is. |
Basing the architecture on I hoped CMake would have a good way to the target architecture but it's OS specific. As for leaving the STDCALL code "as is", doing so will result in build failures for non-x86/x86_64 targets. I'll update the code. |
24d06b0
to
6a1d3bb
Compare
@winterheart, I have revised the code to exclude non-C++17 compilers and removed duplicate detection macros. I hope this is now sufficiently terse. |
Prevent the code from trying to use stdcall for anything except (32-bit) x86 builds because it's the only platform it's applicable for.
Ensure STDCALL/STDCALLPTR is only invoked on x86
Prevent the code from trying to use stdcall for anything except (32-bit) x86 builds because it's the only platform it's applicable for.
This clears up a lot of annoying warning messages.
Alteration to CMakeList.txt is only whitespace clean up.