GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-107249: Implement Py_UNUSED() for MSVC by vstinner · Pull Request #107250 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jul 25, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Fix warnings C4100 in Py_UNUSED() when Python is built with "cl /W4".

Example with this function included by Python.h:

static inline unsigned int
PyUnicode_IS_READY(PyObject* Py_UNUSED(op))
{ return 1; }

Without this change, building a C program with "cl /W4" which just includes Python.h emits the warning:

Include\cpython/unicodeobject.h(199):
warning C4100: '_unused_op': unreferenced formal parameter

This change fix this warning.

  • Issue: Implement Py_UNUSED() for Windows MSVC compiler #107249

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
pythongh-107249: Implement Py_UNUSED() for MSVC
b9cc3b6
Fix warnings C4100 in Py_UNUSED() when Python is built with "cl /W4".

Example with this function included by Python.h:

    static inline unsigned int
    PyUnicode_IS_READY(PyObject* Py_UNUSED(op))
    { return 1; }

Without this change, building a C program with "cl /W4" which just
includes Python.h emits the warning:

    Include\cpython/unicodeobject.h(199):
    warning C4100: '_unused_op': unreferenced formal parameter

This change fix this warning.
@bedevere-bot bedevere-bot mentioned this pull request Jul 25, 2023
Implement Py_UNUSED() for Windows MSVC compiler #107249
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Jul 25, 2023
@vstinner

vstinner commented Jul 25, 2023

Copy link
Copy Markdown
Member Author

@zooba @serhiy-storchaka @methane: Do you want to trade a review? I consider that it's a feature change, so it requires to be approved to be merged, following new Steering Council guidelines :-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jul 25, 2023

Copy link
Copy Markdown
Member Author

Do you think that it would too late to backport it to Python 3.12? We are close to Python 3.12.0 beta 4 (Tuesday, 2023-07-11). I'm not sure if it's a bugfix or a feature :-/ But I would prefer to not backport it to Python 3.11 since I'm not 100% sure that my solution works in all cases on all MSVC versions.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@methane

methane commented Jul 25, 2023

Copy link
Copy Markdown
Member

But I would prefer to not backport it to Python 3.11 since I'm not 100% sure that my solution works in all cases on all MSVC versions.

+1.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

methane
methane approved these changes Jul 25, 2023
View reviewed changes

@methane methane left a comment

Copy link
Copy Markdown
Member

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.

(void)name; in function name might be the simplest solution.
But existing Py_UNUSED() macro is used in function signature.
So I don't know better approach than this PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Jul 25, 2023
@vstinner
vstinner merged commit 6a43cce into python:main Jul 25, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Jul 25, 2023
@vstinner
vstinner deleted the py_unused_msvc branch July 25, 2023 17:28
@vstinner

vstinner commented Jul 25, 2023

Copy link
Copy Markdown
Member Author

Thanks for the review @methane. I merged my PR.

(void)name; in function name might be the simplest solution

Is it possible to put ; in the argument list? int test(int arg) { return 0; } would become int test(int (void)arg;) { return 0; }?

Well, Python 3.12 is already at beta stage. I prefer to not cause any regression. Let's wait until Python 3.13 is shipped. I don't think that this change is so important that it deserves to be backported.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner mentioned this pull request Jul 25, 2023
object.h uses an anonymous union in a struct (older C incompatible) #105059
Closed
@serhiy-storchaka

serhiy-storchaka commented Jul 25, 2023

Copy link
Copy Markdown
Member

C++17 supports

int test([[maybe_unused]] int arg)

I am not sure, but maybe it can be also written as

int test(int [[maybe_unused]] arg)

or

int test(int arg [[maybe_unused]])

If it is so, it can be utilized by Py_UNUSED() in extensions written in C++17.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jtcave pushed a commit to jtcave/cpython that referenced this pull request Jul 27, 2023
@vstinner @jtcave
pythongh-107249: Implement Py_UNUSED() for MSVC (python#107250)
f7f712e
Fix warnings C4100 in Py_UNUSED() when Python is built with "cl /W4".

Example with this function included by Python.h:

    static inline unsigned int
    PyUnicode_IS_READY(PyObject* Py_UNUSED(op))
    { return 1; }

Without this change, building a C program with "cl /W4" which just
includes Python.h emits the warning:

    Include\cpython/unicodeobject.h(199):
    warning C4100: '_unused_op': unreferenced formal parameter

This change fix this warning.
@vstinner vstinner added the needs backport to 3.12 only security fixes label Dec 13, 2024
@miss-islington-app

miss-islington-app Bot commented Dec 13, 2024

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 13, 2024
@vstinner @miss-islington
pythongh-107249: Implement Py_UNUSED() for MSVC (pythonGH-107250)
3e904d1
Fix warnings C4100 in Py_UNUSED() when Python is built with "cl /W4".

Example with this function included by Python.h:

    static inline unsigned int
    PyUnicode_IS_READY(PyObject* Py_UNUSED(op))
    { return 1; }

Without this change, building a C program with "cl /W4" which just
includes Python.h emits the warning:

    Include\cpython/unicodeobject.h(199):
    warning C4100: '_unused_op': unreferenced formal parameter

This change fix this warning.
(cherry picked from commit 6a43cce)

Co-authored-by: Victor Stinner <[email protected]>
@bedevere-app

bedevere-app Bot commented Dec 13, 2024

Copy link
Copy Markdown

GH-127907 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Dec 13, 2024
@vstinner

vstinner commented Dec 13, 2024

Copy link
Copy Markdown
Member Author

GH-127907 is a backport of this pull request to the 3.12 branch.

I need this to backport test_cext to 3.12: issue gh-127906.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner added a commit that referenced this pull request Dec 13, 2024
@miss-islington @vstinner
[3.12] gh-107249: Implement Py_UNUSED() for MSVC (GH-107250) (#127907)
f3a689f
gh-107249: Implement Py_UNUSED() for MSVC (GH-107250)

Fix warnings C4100 in Py_UNUSED() when Python is built with "cl /W4".

Example with this function included by Python.h:

    static inline unsigned int
    PyUnicode_IS_READY(PyObject* Py_UNUSED(op))
    { return 1; }

Without this change, building a C program with "cl /W4" which just
includes Python.h emits the warning:

    Include\cpython/unicodeobject.h(199):
    warning C4100: '_unused_op': unreferenced formal parameter

This change fix this warning.
(cherry picked from commit 6a43cce)

Co-authored-by: Victor Stinner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@methane methane methane approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@vstinner @methane @serhiy-storchaka @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.