2008/11/22 Max Kellermann <max@...>:
> On 2008/11/21 21:29, Kodest <kodest@...> wrote:
>> I think we should consider using this at least where I pointed in the
>> wavpack plug-in, but maybe there are more places in the mpd code where
>> assert()s could be replaced by assert_static()s, or where
>> assert_static()s could be introduced. So, assert_static() should be
>> defined in a common header file.
>> Tell me if we have already a solution to this problem.
> We don't have that currently, but it sounds like a good idea. Keep in
> mind that assertions don't generate any machine code with -DNDEBUG, so
> the advantage over "real" assert() is very small in this regard; it's
> however useful because you don't have to execute the code to see the
> error. But if you see places where a compile-time assertion is more
> useful, why not. I'll accept patches.
I have two patches, both of them can be found in my repo.
457a6f4b utils: introduce assert_static()
a493aafe wavpack: use assert_static()
I tested it with gcc-4.1.2.
Good case warnings/errors: none
Bad case warnings/errors:
decoder/wavpack_plugin.c: In function 'format_samples_int':
decoder/wavpack_plugin.c:75: warning: division by zero
decoder/wavpack_plugin.c:75: error: enumerator value for
'assert_static__' is not an integer constant
This is not the nice "Assertion failed ..." message, but it refers to
assert_static, so the situation can be figured out.