Open
Conversation
added 7 commits
January 14, 2018 13:25
The mechanisms to define the target windows version is to define the appropriate macro before including SDKDDKVer.h. See targetver.h for more details.
_WIN32 is defined by the compiler to tell the code that it is compiled under a 32 bit version of Windows and later. Thus it is also defined under a 64 Bit version of Windows. It's also used by minGW. WIN32 (without underscore) is *not* defined automatically neither by VC++ nor by minGW. Which is probably the reason the code compiled in teh first place, because the __stdcall had been misplaced. See: https://stackoverflow.com/questions/9025708/mingw-not-defining-win32-error-in-preprocessor-directives
When explicitly giving a calling convention it has to directly precede the functions name like this: void __stdcall foo(); The calling convention had been baked into the USB_DMX_DLL macro that defines the dll import/export specifics resulting to: __declspec(dllexport) __stdcall void foo(); which in turn leads to a compiler error. Apparently this did not show up in minGW, because the WIN32 macro had been used to determine the windows version, not the _WIN32 macro. The WIN32 macro however had not been defined. This has been corrected using two dedicated macros, one for the dll magic and another one for the calling convention. Additionally the dll magic has been improved to either turn to the dllexport when compiling the implementation or to dllimport, when using the header from a third party client. This is chosen by the USB_DMX_IMPLEMENTATION macro that is defined in the implementation file before including the usbdmx.h file A similar error had been in the callback typedefs. Here the calling convention has to go inside the brackets: typedef void (__stdcall foo)(); // correct instead of typedef void __stdcall (foo)(); // compiler error
The project file can be used from any other solution to include the usbdmx dll directly into the project. A single solution may be added later to generate the dlls independently.
Owner
|
This breaks |
- rename USB_DMX_CALLBACK to USB_DMX_CALLBACK_CALLING_CONVENTION - add a legacy define for USB_DMX_CALLBACK until it maybe becomes deprecated
Author
|
My bad, I missed the example program. Changed the macro there and re-introduced the USB_DMX_CALLBACK macro in order to not break other existing project. If it's OK by you it could be marked deprecated in future releases. It's just a naming clarification. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compiler macros and MSVC specific settings have been added to correctly compile under MSVC in VS 2017. The other pull requests should go together with this one, to compile without warnings.