-
-
Notifications
You must be signed in to change notification settings - Fork 781
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
Msvc fixes #1661
Msvc fixes #1661
Conversation
b800c5f
to
968bfef
Compare
This builds and work with I think I need to work on setting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good - there are a couple of items we've spotted in review but with them addressed, we'll be happy to merge this and open the pathway to full MSVC support in the future.
We've decided that, as much as VLAs need fixing.. by making them all alloca()
's like this does, it makes them stand out far better than an innocent looking T name[len];
, so that'll make finding and fixing them all easier going forward.
That should address all of the concerns mentioned here, as well as fixing the merge with the new |
Indeed, the only other thing we see in checking the commit messages is that the first commit in the series doesn't have its colon prefix - we'd suggest |
Replace all variable-length arrays with a call to `alloca()`. This doesn't solve the problem, and merely papers over it. However, there are two benefits to this approach: 1. We can now grep for `alloca()` in order to find all uses of VLAs 2. This helps to build under MSVC, which simply doesn't support VLAs Signed-off-by: Sean Cross <[email protected]>
Pointer math on void pointers is undefined. With GCC it is the same as a char pointer, but MSVC simply refuses to compile them. Replace math on `void *` with math on `uint8_t *`. As a side effect, this helps to build under MSVC. Signed-off-by: Sean Cross <[email protected]>
MSVC doesn't have either of these symbols defined. However, they are just alises for existing types, so manually redefine these in the target header file. Signed-off-by: Sean Cross <[email protected]>
The MSVC compiler is extremely picky when it comes to assigning const values. Whereas GCC will allow you to add two `const` variables, MSVC will not let you use any input variables when assigning to a global const. Work around this by using the C preprocessor to define `MAX_PORT` that includes a CPP definition of `DEFAULT_PORT`, then combine these two to assign to `max_port`. This fixes the build under MSVC. Signed-off-by: Sean Cross <[email protected]>
Good suggestion. I've updated that now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, merging. Thank you for the contribution!
Detailed description
This includes several fixes that help to build under MSVC. In particular, this helps me to build blackmagic as a module under Rust, which effectively uses Cargo to drive MSVC.
There are two broad classes of fixes:
void *
was replaced with pointer math onuint8_t *
where necessary. This is because MSVC refuses to compile this type of code, ahd it's UB anyway. It was assumed thatvoid *
math is the same asuint8_t *
math.alloca()
instead.There are additional fixes for missing features on MSVC, however this includes most of the fixes in my local branch.
Your checklist for this pull request
make PROBE_HOST=native
)make PROBE_HOST=hosted
)