diff --git a/onnx/defs/schema.h b/onnx/defs/schema.h index acf3aac..adae2d5 100644 --- a/onnx/defs/schema.h +++ b/onnx/defs/schema.h @@ -979,8 +979,10 @@ class OpSchemaRegistry final : public ISchemaRegistry { class OpSchemaRegisterOnce final { public: - // Export to cpp custom register macro - explicit OpSchemaRegisterOnce( + // Export to cpp custom register macro. + // DO NOT decorate the constructor as "explicit" because that breaks the macro ONNX_OPERATOR_SCHEMA_UNIQ. + // NOLINTNEXTLINE(google-explicit-constructor) + OpSchemaRegisterOnce( // NOSONAR OpSchema op_schema, int opset_version_to_load = 0, bool fail_duplicate_schema = true) { @@ -1311,9 +1313,9 @@ size_t ReplaceAll(std::string& s, const char* from, const char* to); // Legacy macros to register schema at static initialization #define ONNX_OPERATOR_SCHEMA(name) ONNX_OPERATOR_SCHEMA_UNIQ_HELPER(__COUNTER__, name) #define ONNX_OPERATOR_SCHEMA_UNIQ_HELPER(Counter, name) ONNX_OPERATOR_SCHEMA_UNIQ(Counter, name) -#define ONNX_OPERATOR_SCHEMA_UNIQ(Counter, name) \ - static ONNX_NAMESPACE::OpSchemaRegistry::OpSchemaRegisterOnce(op_schema_register_once##name##Counter) ONNX_UNUSED = \ - OpSchema(#name, __FILE__, __LINE__) +#define ONNX_OPERATOR_SCHEMA_UNIQ(Counter, name) \ + static ONNX_NAMESPACE::OpSchemaRegistry::OpSchemaRegisterOnce op_schema_register_once##name##Counter ONNX_UNUSED = \ + ONNX_NAMESPACE::OpSchema(#name, __FILE__, __LINE__) // Helper function size_t ReplaceAll(std::string& s, const char* from, const char* to);