Skip to content

[BUG]: Underscore function conflicts with gettext common usage #3401

@sethhillbrand

Description

@sethhillbrand

Required prerequisites

Problem description

The use of _ as a function in detail/descr.h conflicts with the common macro usage of _() to denote gettext().

The use of _ for translation is baked into multiple programs, e.g. wxFormBuilder to generate code for frameworks (wxWidgets) that expect the macro.

While this macro is only a suggestion in the gettext manual [1], it is built into expectations[2][3][4][5].

Since the pybind11 usage is internal, would we be able to rename the pybind11 functions from _ to something similarly short like x?

[1] http://www.gnu.org/software/gettext/manual/gettext.html#Overview
[2] https://forums.wxwidgets.org/viewtopic.php?t=19062
[3] https://stackoverflow.com/q/15244397/995714
[4] https://stackoverflow.com/q/15244397/995714
[5] https://stackoverflow.com/questions/3336056/underscore-before-the-format-string

Reproducible example code

#define _(s) gettext(s)
#include <pybind11/pybind11.h>

namespace py = pybind11;

PYBIND11_MODULE(gettext_test, m) {
    m.attr("test") = "test";
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew bug, unverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions