Closed zschoenstadt closed 9 years ago
While this library uses GNU extensions (so non-standard C) and hence is unlikely to have any projects compiling with -pedantic
, the sentinel is most surely still needed for those compiling with -Wmissing-field-initializers
and -Werror
, and nobody will mourn the loss of a padded integer worth of stack size.
Since the use case is a bit unusual, I won't change the interface as-is but make it available with an #ifdef'd alternative. Usage would be in the lines of:
#define CSPTR_NO_SENTINEL
#include <csptr/smart_ptr.h>
I could also make it change with ./configure --without-sentinel and the include clause would be unchanged.
Does that sound good ?
Edit: added ./configure alternative
You do not need to change the interface on my account, since you are right about it making the code ugly. Your point about the ISO C standard is valid, and quite respectable. I can fork if need be.
If you decide to make the change anyway, yes that looks like a great compromise.
One could use -DCSPTR_NO_SENTINEL
on the command line if there was a desire not to define it in the source before the include.
One could use -DCSPTR_NO_SENTINEL on the command line if there was a desire not to define it in the source before the include.
After a bit of thinking, this would not work in this case (as well as the #define alternative), as the definition of the arguments structure would differ between the library binary and the user program. I will have to pass it as a switch for ./configure.
Fixed in 2.0.3.
The use of the sentinel in the variadic macro pattern is not necessary. The following is valid C and compiles using both gcc-4.4.7 and clang-3.4.2.
edit: Clang also produces no compiler warnings at -Wextra. I understand the desire to maintain ISO compatibility, however, this was not apparent as other GCC/Clang extensions are used, such as the named variadic macro.
edit2: missing context from blog post: