Skip to content

Commit

Permalink
strategically placed comment about -pedantic related change requests
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Jan 25, 2024
1 parent 1d8b5a8 commit 6d91800
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions include/nanobind/nb_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,37 @@ template <size_t Size> struct func_data_prelim {
const char *doc;
PyObject *scope;

// *WARNING*: nanobind regularly receives requests from users who run it
// through Clang-Tidy, or who compile with increased warnings levels, like
//
// -Wpedantic, -Wcast-qual, -Wsign-conversion, etc.
//
// (i.e., beyond -Wall -Wextra and /W4 that are currently already used)
//
// Their next step is to open a big pull request needed to silence all of
// the resulting messages. This comment is strategically placed here
// because the zero-length array construction below will almost certainly
// be flagged in this process.
//
// My policy on this is as follows: I am always happy to fix issues in the
// codebase. However, many of the resulting change requests are in the
// "ritual purification" category: things that cause churn, decrease
// readability, and which don't fix actual problems. It's a never-ending
// cycle because each new revision of such tooling adds further warnings
// and purification rites.
//
// So just to be clear: I do not wish to pepper this codebase with
// "const_cast" and #pragmas/comments to avoid warnings in external
// tooling just so those users can have a "silent" build. I don't think it
// is reasonable for them to impose their own style on this project.
//
// As a workaround it is likely possible to restrict the scope of style
// checks to particular C++ namespaces or source code locations.
#if defined(_MSC_VER)
// MSVC doesn't support zero-length arrays
arg_data args[Size == 0 ? 1 : Size];
#else
// GCC and Clang do.
arg_data args[Size];
#endif
};
Expand Down

0 comments on commit 6d91800

Please sign in to comment.