Skip to content

Why is linking to Python debug library disabled for Windows? #1295

@Toninoso

Description

@Toninoso

From detail/common.h

/// Include Python header, disable linking to pythonX_d.lib on Windows in debug mode
#if defined(_MSC_VER)
#  if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 4)
#    define HAVE_ROUND 1
#  endif
#  pragma warning(push)
#  pragma warning(disable: 4510 4610 4512 4005)
#  if defined(_DEBUG)
#    define PYBIND11_DEBUG_MARKER
#    undef _DEBUG
#  endif
#endif

Since I need debug build #undef _DEBUG caused me a lot of grief until I dicovered it.

On top of wanting to be able to debug my own code, I don't mind being able to step through Python for Windows dll code as well. In fact, in a few cases it was very useful.

Could anyone please explain why would one want to #undef _DEBUG?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions