json icon indicating copy to clipboard operation
json copied to clipboard

Fix NLOHMANN_DEFINE_TYPE_* macros for zero-member types

Open chelseadzdr opened this issue 2 months ago • 3 comments

This pull request solves the issue #4041 using the changes made in the closed PR #4323

  • [x] The changes are described in detail, both the what and why.
  • [x] If applicable, an existing issue is referenced.
  • [x] The Code coverage remained at 100%. A test case for every new line of code.
  • [ ] If applicable, the documentation is updated.
  • [x] The source code is amalgamated by running make amalgamate.

When any of the NLOHMANN_DEFINE_TYPE_* macros are used with no data members, the preprocessor currently expands VA_ARGS to an empty token. This leads to invalid code which breaks compilation for empty types.

This PR adjusts the macro_scope so that the zero-member case is handled explicitly. It finishes the work made in #4323 keeping the new changes like "Generate template functions with NLOHMANN_DEFINE_TYPE macros (#4597)" and to keep the documentations added.

Because develop has moved on since #4323, the changes were reapplied and adjusted manually rather than via a direct merge.

Tests has been included.

chelseadzdr avatar Nov 13 '25 00:11 chelseadzdr

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @chelseadzdr Please read and follow the Contribution Guidelines.

github-actions[bot] avatar Nov 13 '25 05:11 github-actions[bot]

Coverage Status

coverage: 99.191%. remained the same when pulling 4c1689c52c6948e83b5ba9d2e275739b223c05d3 on chelseadzdr:fix-serialization into 49026f799983840d7cf1a8109ffffe7eb4b1012c on nlohmann:develop.

coveralls avatar Nov 13 '25 05:11 coveralls

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @chelseadzdr Please read and follow the Contribution Guidelines.

github-actions[bot] avatar Nov 13 '25 19:11 github-actions[bot]