Kronometer 1.2.2 released
A new bugfix release for kronometer is now available. The release 1.2.2 fixes a small bug that was preventing the compilation with older gcc
versions. Since this bug was also well hidden I think that it’s worth a blog post.
The bug consisted in two trailing commas forgotten in two enum definitions.
Well, actually this is a bug only with certain versions of C and C++ and I didn’t know it.
A trailing comma in an enum declaration is a comma after the last enum member:
Let’s see where this code compiles and where it doesn’t (credits to this stackoverflow answer):
- C89 doesn’t allow the trailing comma
- C99 does allow it
- C++98 and C++03 don’t allow it, since their C compatibility is based on C89
- C++11 does allow it
The default compiler options used by kronometer are:
-Wall -Wextra -Werror -ansi -pedantic -std=gnu++0x
.
Kronometer uses some small features of C++11, like nullptr
. That’s why the flag -std=gnu++0x
.
Here there was the problem: the flag -pedantic
triggers a compilation error when it finds the trailing commas. This warning is ignored if C++11 is enabled, but only on recent enough versions of gcc. Since I use gcc 4.8.1 I didn’t find the bug. By removing those commas, now kronometer should be fully compilable also on older compilers.