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

Building with MSVC #31

Closed
kyursen opened this issue Nov 10, 2016 · 3 comments
Closed

Building with MSVC #31

kyursen opened this issue Nov 10, 2016 · 3 comments
Milestone

Comments

@kyursen
Copy link
Contributor

kyursen commented Nov 10, 2016

Is it fine for libcbor to be buildable with MSVC (at least with VS 2013)?

It is possible, but the cost is losing the C99 compliance:

  1. Replace C99 restrict keyword with MSVC-specific __restrict.
  2. The same is with inline - replace it with __inline.

These two replacements can be made via CMakeLists:

if(MSVC)
    set(CBOR_RESTRICT "__restrict")
    set(CBOR_INLINE "__inline")
else()
    set(CBOR_RESTRICT "restrict")
    set(CBOR_INLINE "inline")
endif()
  1. #include <stdlib.h> instead of #include <unistd.h>.
  2. Add const parameter qualifier to cbor_new_definite_map/array implementations (typo?).
@kyursen
Copy link
Contributor Author

kyursen commented Nov 11, 2016

I may prepare a PR from a test branch https://github.com/kyursen/libcbor/tree/msvc (after some cleanups)

@PJK PJK added this to the v0.5 milestone Jan 4, 2017
@PJK
Copy link
Owner

PJK commented Jan 6, 2017

Is it fine for libcbor to be buildable with MSVC (at least with VS 2013)?

Of course

Thank you for your suggestions, I've implemented most of them #47. inline and restrict didn't work as expected (in particular I don't understand why __inline in the source file makes the symbols disappear: https://ci.appveyor.com/project/PJK/libcbor/build/15, I plan on removing it anyway), but those are not fundamental limitations.

@PJK PJK closed this as completed Jan 6, 2017
@kyursen
Copy link
Contributor Author

kyursen commented Jan 8, 2017

Thank you!

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

No branches or pull requests

2 participants