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

windows: Fix redefinition errors in some build environments #1509

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oleavr
Copy link

@oleavr oleavr commented Jun 11, 2024

By including winsock2.h before windows.h.

@Youw
Copy link
Member

Youw commented Jun 11, 2024

Add a comment explaining that it has to stay in that order an why

By including winsock2.h before windows.h.

Co-authored-by: Håvard Sørbø <[email protected]>
@oleavr oleavr force-pushed the submit/fix-windows-redefinition-errors branch from f6296ec to a303952 Compare June 11, 2024 08:51
@oleavr
Copy link
Author

oleavr commented Jun 11, 2024

Add a comment explaining that it has to stay in that order an why

Good point, thanks! Just updated the commit.

@mcuee mcuee added the windows label Jun 11, 2024
@mcuee
Copy link
Member

mcuee commented Jun 11, 2024

I have never been a fan of Cygwin but it is good that people are providing PRs for Cygwin.
Edit -- this comment is not correct.

Copy link
Member

@Youw Youw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tormodvolden
Copy link
Contributor

This change only affects non-Cygwin Window builds, doesn't it? To be more precise and avoid confusion, can you please rephrase "some build environments"? Are these redefinition errors visible on any of our CI runs?

@mcuee
Copy link
Member

mcuee commented Jun 17, 2024

This change only affects non-Cygwin Window builds, doesn't it? To be more precise and avoid confusion, can you please rephrase "some build environments"? Are these redefinition errors visible on any of our CI runs?

Good point.

I wrongly assumed the fix is for Cygwin, but actually it is not for Cygwin but for non-Cygwin.

I never see such issues with MSYS2 mingw build environment and MSVC. So I tend to think this PR may not be needed.

@tormodvolden
Copy link
Contributor

If I understand https://stackoverflow.com/questions/9153911/is-there-a-difference-between-winsock-h-and-winsock2-h correctly, windows.h will include winsock.h and then winsock2.h cannot be included afterwards because it will try to redefine stuff. But if winsock2.h is included first, any following winsock.h will not be parsed and everything is fine.

So if a program includes winsock2.h before libusb.h there shouldn't be any problem, right? Is that why we haven't heard complaints before?

From looking up commit 0ded9c1 , commit eea7ebe , commit 2442719 it seems winsock was introduced only for WinCE and for WDK. I don't think we support WinCE any longer, and WDK I have no idea about. Do we need to include winsock*.h at all? Is this about WinCE?

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

Successfully merging this pull request may close these issues.

None yet

5 participants