Visual C++ Compatibility#28
Closed
qmfrederik wants to merge 6 commits intolibimobiledevice:masterfrom
Closed
Conversation
Add msc_config.h file which contains definitions for inline, __func__ and various definitions that make the Visual C++ compiler be compatible with the libusbmuxd codebase collection.c, socket.c, libusbmuxd.c: Include msc_config.h
Move config.h, msc_config.h to the top o
Packing structs is done differently on MSVC and GCC
Visual C++ requires the declaration of methods to be exactly the same in the .h and .c files; otherwise it throws C2375. This is fixed by: - Defining USBMUXD_API_MSC in the public headers (via usbmuxd.h) which will add __declspec( dllexport ) to all method definitions in the public headers when compiling with Visual C++ - Ensuring USBMUXD_API_MSC is always set to __declspec( dllexport ) in the private source files when compiling with Visual C++. Using USBMUXD_API in the public headers does not work, becuase its value depends on HAVE_FVISIBILITY, which may be defined in config.h, which is not a public header.
Include unistd.h in libusbmuxd.c Define strcasecmp for Visual C++ compat
Include unistd.h on non-WIN32 builds
17 tasks
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.
This pull request fixes incompatibilities between the Visual C++ compiler and the libusbmuxd codebase.
It consists of these changes:
USBMUXD_API_MSC. On the current codebase, Visual C++ generates a compiler C2375 because the function declarations in the public header and the source files differ. RecylingUSBMUXD_APIin the public headers doesn't work, because it value depends on what is defined inconfig.h, and that's specific to the libimobiledevice build, not what the user is building.Instead, a new define
USBMUXD_API_MSCis used which adds the__declspec( dllexport )prefix only if Visual C++ is used.USBMUXD_APIis updated to always be__declspec( dllexport )when compiling with Visual C++.#includestatements were not compatibile with Visual C++ and this has been fixed. A lot ofunistd.hincludes were redundant and the have been removed.msc_config.hfile, which defines values such as_CRT_SECURE_NO_WARNINGSwhich work around Visual C++ compiler errors, and defines macros, functions,... that don't exist when compiling with the Visual C++ compiler. For example, func is defined as FUNCTION.. This header must be included before any other header is included in the file; it is usually added right after theconfig.hheader.msc_compat.hfile, which overrides function definitions in C++ that create compiler errors. For example, usingstrdupin Visual C++ creates an error asking you to use_strdupinstead. This file definesstrdupas_strdup, working around the issue.The updated code compiles on Linux (see Travis Build ) and Windows (see AppVeyor Build )