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

Removing WIN32 define breaks Windows builds #4854

Closed
crazydef opened this issue Jan 27, 2020 · 10 comments
Closed

Removing WIN32 define breaks Windows builds #4854

crazydef opened this issue Jan 27, 2020 · 10 comments
Labels
build Windows Windows-specific

Comments

@crazydef
Copy link

crazydef commented Jan 27, 2020

I updated to the latest code.

I expected everything to still work.

curl/libcurl version 7.69.0-DEV

operating system: Windows 10

The commit that removes the WIN32 define didn't also remove all references to WIN32 in other places, so now nothing builds on Windows.

I understand the desire to remove WIN32, but existing usage of that macro should have been changed to use the compiler defined _WIN32 at the same time. As things now stand, this non-standard macro needs to be declared externally when building any project that includes curl.h on Windows.

@bagder
Copy link
Member

bagder commented Jan 27, 2020

now nothing builds on Windows.

I'm afraid that's wrong. All of our CI builds on Windows still build perfectly. You need to be much more specific and explain exactly what doesn't build and preferably why.

WIN32 should not be defined by curl headers.

@bagder bagder added build Windows Windows-specific labels Jan 27, 2020
@crazydef
Copy link
Author

Your CI builds probably still build because your toolchain (cmake, by any chance?) defines WIN32 itself. Other build systems (like Visual Studio, for example) do not. Any project which includes curl.h is now forced to define WIN32 on Windows.

@crazydef
Copy link
Author

I agree WIN32 shouldn't be defined by Curl headers. In the same way I agree that the Curl headers shouldn't try to rely on non-standard, user-defined macros to detect the platform.

@bagder
Copy link
Member

bagder commented Jan 27, 2020

Other build systems (like Visual Studio, for example) do not

You mean using the files under projects/Windows ? Then we should fix those builds.

In the same way I agree that the Curl headers shouldn't try to rely on non-standard, user-defined macros to detect the platform.

Feel free to suggest and provide improvements to our headers and other code. We only do the best we can and there is always room for improvements.

@crazydef
Copy link
Author

No, I mean projects that use curl. Not any code in the curl directory. (Although that might be affected too.)

I'm not talking about building curl, I'm talking about including curl.h in my projects.

@bagder
Copy link
Member

bagder commented Jan 27, 2020

Why should curl's headers be responsible for identifying win32 for your projects?

@crazydef
Copy link
Author

Because curl requires WIN32 to be declared. It used to declare it itself if _WIN32 was declared, now it assumes it's declared externally. Curl shouldn't require the user to define the platform. That's the job of compiler writers and OS vendors. Curl should be using _WIN32 (or whatever) to detect the platform. I.e, the standard platform preprocessor definitions.

As for a recommendation, In system.h I would add CURL_WIN32, CURL_MACOS, etc platform definitions and use those throughout the rest of the curl source code.

@bagder
Copy link
Member

bagder commented Jan 27, 2020

Le me try to decipher this.

You're saying that curl uses preprocessor logic in its public header files that relies on WIN32 being defined when it is in fact not usually defined by Windows compilers?

@MarcelRaad
Copy link
Member

@bagder

Why should curl's headers be responsible for identifying win32 for your projects?

It checks for the removed define throughout curl.h, e.g.

#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__CYGWIN__)

@crazydef
Copy link
Author

Yes, that's what I'm saying. :)

bagder added a commit that referenced this issue Jan 27, 2020
... so that the subsequent logic below can use a single known define to know
when built on Windows (as we don't define WIN32 anymore).

Follow-up to 1adebe7

Reported-by: crazydef on github
Fixes #4854
@bagder bagder closed this as completed in 8bd863f Jan 27, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
build Windows Windows-specific
Development

Successfully merging a pull request may close this issue.

3 participants