Skip to content

Implement Py_DEPRECATED() macro for Visual Studio #77588

Closed

Description

@vstinner
BPO 33407
Nosy @pfmoore, @pitrou, @vstinner, @tjguk, @zware, @zooba, @ZackerySpytz
PRs
  • bpo-33407: Implement Py_DEPRECATED() on Windows #8980
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-05-28.15:19:44.920>
    created_at = <Date 2018-05-02.09:29:49.384>
    labels = ['3.8', 'OS-windows']
    title = 'Implement Py_DEPRECATED() macro for Visual Studio'
    updated_at = <Date 2019-05-28.15:19:44.919>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-05-28.15:19:44.919>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-05-28.15:19:44.920>
    closer = 'vstinner'
    components = ['Windows']
    creation = <Date 2018-05-02.09:29:49.384>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33407
    keywords = ['patch']
    message_count = 5.0
    messages = ['316059', '316060', '316061', '343789', '343790']
    nosy_count = 7.0
    nosy_names = ['paul.moore', 'pitrou', 'vstinner', 'tim.golden', 'zach.ware', 'steve.dower', 'ZackerySpytz']
    pr_nums = ['8980']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue33407'
    versions = ['Python 3.8']

    Activity

    1. vstinner commented on May 2, 2018

      @vstinner
      MemberAuthor

      According to the following links, it would be possible to implement the Pc_DEPRECATED() macro for Visual Studio:

      https://mail.python.org/pipermail/python-dev/2018-May/153299.html
      https://stackoverflow.com/questions/295120/c-mark-as-deprecated/295229#295229

      """
      #ifdef __GNUC__
      #define DEPRECATED(func) func __attribute__ ((deprecated))
      #elif defined(_MSC_VER)
      #define DEPRECATED(func) __declspec(deprecated) func
      #else
      #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
      #define DEPRECATED(func) func
      #endif
      """

      Moreover, is Py_DEPRECATED() defined on clang which also supports the deprecated function attribute?
      https://clang.llvm.org/docs/AttributeReference.html#deprecated-gnu-deprecated

      Current Include/pyport.h code:

      #if defined(__GNUC__) \
          && ((__GNUC__ >= 4) || (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
      #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
      #else
      #define Py_DEPRECATED(VERSION_UNUSED)
      #endif
    2. vstinner commented on May 2, 2018

      @vstinner
      MemberAuthor

      Oh, bpo-19569 is still open, for Visual Studio see:
      https://bugs.python.org/issue19569#msg227727

    3. pitrou commented on May 2, 2018

      @pitrou
      Member

      In Arrow we use the following:

      #if __cplusplus <= 201103L
      # ifdef __GNUC__
      #  define ARROW_DEPRECATED(...) __attribute__((deprecated(__VA_ARGS__)))
      # elif defined(_MSC_VER)
      #  define ARROW_DEPRECATED(...) __declspec(deprecated(__VA_ARGS__))
      # else
      #  define ARROW_DEPRECATED(...)
      # endif
      #else
      #  define ARROW_DEPRECATED(...) [[deprecated(__VA_ARGS__)]]
      #endif
    4. vstinner commented on May 28, 2019

      @vstinner
      MemberAuthor

      New changeset 3c8724f by Victor Stinner (Zackery Spytz) in branch 'master':
      bpo-33407: Implement Py_DEPRECATED() on MSVC (GH-8980)
      3c8724f

    5. vstinner commented on May 28, 2019

      @vstinner
      MemberAuthor

      Thanks Zackery Spytz for the fix!

    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions