Overview   Class List   Class Hierarchy   Class Members   Functions & Constants   Defines   Header Files  

assertmsg.h File Reference


Detailed Description

. An extension of the assert routine to print a message on failure

-----------------------------------------------------------------------------

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

-----------------------------------------------------------------------------

--------------------------------------------------------------------------


Defines

#define assertWithMsg(expr, msg)   if (!(expr)) {fprintf(stderr,"Assert msg: %s\n",msg);assert(expr);}
  assert prints a diagnostic message to stderr and aborts the program if expression is false (zero).


Define Documentation

#define assertWithMsg expr,
msg   )     if (!(expr)) {fprintf(stderr,"Assert msg: %s\n",msg);assert(expr);}
 

assert prints a diagnostic message to stderr and aborts the program if expression is false (zero).

Use assert to identify program logic errors. Choose an expression that holds true only if the program is operating as you intend. After you have debugged the program, you can use the special no-debug identifier NDEBUG to remove the assert calls from the program. If you define NDEBUG to any value with a #define directive, the C preprocessor expands all assert invocations to void expressions. If you use NDEBUG, you must define it before you include "uima/assertmsg.h" in the program.

There is no return value.

Example:

   foo(const void * cpvP1, const void * cpvP2, int i)
   {
      assert(EXISTS(cpvP1));
      assert(EXISTS(cpvP2));
      assert((i > 0) && (i < 100));
      ...
   }

Note:
assert is no longer implemented here ... the system macro is used. Do not use the #undef directive with assert.
assertWithMsg prints a diagnostic message to stderr and aborts the program if expression is false (zero).

assertWithMsg has the same purpose as assert with the additional feature that you can pass an additional message string to the function which gets displayed in case the specified expression evaluates to false (zero).

Use assertWithMsg to identify program logic errors. Choose an expression that holds true only if the program is operating as you intend. After you have debugged the program, you can use the special no-debug identifier NDEBUG to remove the assertWithMsg calls from the program. If you define NDEBUG to any value with a #define directive, the C preprocessor expands all assertWithMsg invocations to void expressions. If you use NDEBUG, you must define it before you include "uima/assertmsg.h" in the program.

There is no return value.

Example:

   foo(const void * cpvP1, const void * cpvP2, int i)
   {
      assert(EXISTS(cpvP1));
      assert(EXISTS(cpvP2));
      assertWithMsg(((i > 0) && (i < 100)), "invalid value specified");
      ...
   }
Note:
assertWithMsg is implemented as a macro. Do not use the #undef directive with assertWithMsg.
See also:
assert


Generated on Mon Oct 1 16:04:12 2012 for UIMACPP API by  doxygen 1.3.9.1