Open thomthom opened 1 year ago
Ah, this isn't for suppressing warnings. It's been a while when I did this, but (I think) it served the purpose of easily removing variables that were created for assert() checks, for production builds. I need the asserts for debugging.
How is this removing any variable?
Looking at how it's used:
The results
variable is created regardless. But in Release it'll be unused and produce a warning.
This should do the same, but with newer C++ semantics.
SUTypedValueRef TypedValue::create_typed_value() {
SUTypedValueRef typed_value = SU_INVALID;
[[maybe_unused]] auto res = SUTypedValueCreate(&typed_value);
assert(res == SU_ERROR_NONE);
return typed_value;
}
OK, thank for the tip. I will implement that. The wrapper was made initially with C++14, so I will get on and make those changes.
I've been recently migrating my projects to C++20 and it's adding quite a few nice features. Even C++17 add a good chunk of useful improvements to the language.
Not sure what this project's C++ version policy is, but since C++17 we have
[[maybe_unused]]
that can suppress unused variable warnings.https://github.com/TommyKaneko/Sketchup-API-C-Wrapper/blob/6879346ce7ca292962e40246e4f587020fcc9273/src/SUAPI-CppWrapper/model/TypedValue.cpp#L28-L29