Skip to content

Replace sscanf by sscanf_s on Windows? #1314

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

Closed
anntzer opened this issue Mar 10, 2018 · 1 comment
Closed

Replace sscanf by sscanf_s on Windows? #1314

anntzer opened this issue Mar 10, 2018 · 1 comment

Comments

@anntzer
Copy link
Contributor

anntzer commented Mar 10, 2018

Issue description

PYBIND11_PLUGIN currently uses sscanf to parse the output of Py_GetVersion(). On MSVC, the use of sscanf triggers a warning:

warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

Obviously 1) the warning is spurious (the literal format used is totally safe) and 2) the programmer could, indeed, set _CRT_SECURE_NO_WARNINGS; but still, perhaps pybind11 could just use sscanf_s there?

Reproducible example code

N/A

jagerman added a commit to jagerman/pybind11 that referenced this issue Mar 10, 2018
This reimplements the version check to avoid sscanf (which has
reportedly started throwing warnings under MSVC, even when used
perfectly safely -- pybind#1314).  It also extracts the mostly duplicated
parts of PYBIND11_MODULE/PYBIND11_PLUGIN into separate macros.
@jagerman
Copy link
Member

I'm testing a fix (linked above via commit message reference) for this by just building and checking for the major/minor version string prefix we expect (rather than doing any string-to-integer conversion at all).

jagerman added a commit to jagerman/pybind11 that referenced this issue Mar 10, 2018
This reimplements the version check to avoid sscanf (which has
reportedly started throwing warnings under MSVC, even when used
perfectly safely -- pybind#1314).  It also extracts the mostly duplicated
parts of PYBIND11_MODULE/PYBIND11_PLUGIN into separate macros.
jagerman added a commit that referenced this issue Mar 11, 2018
This reimplements the version check to avoid sscanf (which has
reportedly started throwing warnings under MSVC, even when used
perfectly safely -- #1314).  It also extracts the mostly duplicated
parts of PYBIND11_MODULE/PYBIND11_PLUGIN into separate macros.
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

No branches or pull requests

2 participants