0

Is there a verify() function (Such as VERIFY() in msvc) or similar that is in the standard c libraries or do I have to write my own? If so, which header is it under?

Edit: The difference between assert and verify is that verify will still execute the function in a release build, whereas the statement in assert is not compiled in release.

I.e.

assert( printf("assert ") );

verify( printf("verify") );

in debug will print "assert verify" but in release will print "verify".

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
ashleysmithgpu
  • 1,867
  • 20
  • 39
  • It is entirely up to you whether asserts are enabled in your release build - this is controlled by the `NDEBUG` macro. – Paul R Jun 14 '12 at 12:00
  • I see, the answer is no then, it's just a microsoft thing. – ashleysmithgpu Jun 14 '12 at 13:11
  • If you prefer doing things the Microsoft way then you can just compile with e.g. `gcc -DVERIFY=assert ...` but it's probably better to be portable and just use `assert` in your code. – Paul R Jun 14 '12 at 14:01

3 Answers3

4

At runtime, C has the assert macro in assert.h.

At compile time, C (since C11) has the static_assert macro in assert.h.

For information, for static_assert some C89/C99 compilers also include it as a compiler extension. For example IAR compiler has the static_assert function in intrinsics.h.

ouah
  • 142,963
  • 15
  • 272
  • 331
0

You could use CUnit for unit testing. It is a C port of the good old JUnit library for Java.

Later edit: it seems there is a similar macro which I did not know about.

0

You could use the assert macro defined in assert.h

smichak
  • 4,716
  • 3
  • 35
  • 47