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

Remove backup implementation of Round for Windows platforms #6693

Merged
merged 1 commit into from Oct 29, 2022
Merged

Remove backup implementation of Round for Windows platforms #6693

merged 1 commit into from Oct 29, 2022

Conversation

cgohlke
Copy link
Contributor

@cgohlke cgohlke commented Oct 27, 2022

Fixes link error on Visual Studio 2019 14.29.30133 with Windows 10 SDK 10.0.19041.0:

ucrt.lib(api-ms-win-crt-math-l1-1-0.dll) : error LNK2005: round already defined in Convert.obj
   Creating library build\temp.win-amd64-3.10\Release\src\_imaging.cp310-win_amd64.lib and object build\temp.win-amd64-3.10\Release\src\_imaging.cp310-win_amd64.exp
build\lib.win-amd64-3.10\PIL\_imaging.cp310-win_amd64.pyd : fatal error LNK1169: one or more multiply defined symbols found
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\link.exe' failed with exit code 1169

@cgohlke cgohlke changed the title WIP: Remove backup implementation of Round for Windows platforms Remove backup implementation of Round for Windows platforms Oct 27, 2022
@radarhere
Copy link
Member

This is reverting 9d00686

@cgohlke
Copy link
Contributor Author

cgohlke commented Oct 28, 2022

#ifndef round
double
round(double x) {
return floor(x + 0.5);
}
#endif

The use of #ifndef round looks wrong here. #ifndef checks whether a macro is not defined but round is a function declared in math.h (or not; it's only part of the C99 standard).

@nulano
Copy link
Contributor

nulano commented Oct 28, 2022

FWIW https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=msvc-170#c-standard-library-features-1 suggests that round support was added in VS2015, which is the minimum required for packages compatible with CPython 3.5 or newer.

The oldest supported Visual Studio in winbuild/build_prepare.py is currently VS 2017, and I've been considering increasing that to VS 2019.

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

3 participants