Skip to content
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

Add Visual C++ support (rebased) #76

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

qmfrederik
Copy link
Contributor

This is a rebased version of #63 and should do pretty much the same thing as #69, #49, #4 and #5 .

This pull request adds support for Microsoft Visual C++ in libplist.

It only includes changes in the .h and .c files; the actual project files are not included to keep the libplist repository clean.

A lot of the changes are minor; for example, VC++ is more picky about implicit casts so a lot of cast statements have been added. Similarly, if the declaration in the .h and .c file differ, VC++ complains. Hence a lot of PLIST_API_MSC statements have been added in the .h files.

Care has been taken to make sure that VC++ -specific statements are wrapped in an #ifdef _MVC_VER statement, so that they won't interfere with other compilers on the Windows platform.

I used Travis as a CI server in the upstream repository, to verify compilation still works on the Linux platform. It did, and you can see the result here: https://travis-ci.org/libimobiledevice-win32/libplist/builds/130135945
The upstream repository also contains a sample .travis.yml file that you could use if you wanted CI; it is not included in this pull request.

Similarly, I also tested on a Windows machine using AppVeyor and you can see the results here: https://ci.appveyor.com/project/qmfrederik/libplist/

All feedback is welcome,

Frederik.

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 PLIST_API_MSC in the public headers (via plist.h) which will add __declspec( dllexport ) to all method definitions in the public headers when compiling with Visual C++
- Ensuring PLIST_API is always set to __declspec( dllexport ) in the private source files when compiling with Visual C++.

Using PLIST_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.
Add msc_config.h file which contains definitions for inline, __func__ and various definitions that make the Visual C++ compiler be compatible with the libplist codebase
@qmfrederik
Copy link
Contributor Author

@nikias , I've seen you accept some PRs in libplist lately. Just wondering - anything specific that needs to be done in this PR for you to be able to accept it?

Thanks!

@AiXanadu
Copy link

AiXanadu commented Oct 7, 2021

I think we really need a compiled version that supports MSVC.

After all, it is difficult for some people who use MSVC to debug dynamic libraries compiled by MinGW or other compilers.

This hardly changes much and has no impact on the existing logic. This can be done by replacing header files, exporting macros and some macros unique to Linux.

Looking forward to...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants