BDE 4.14.0 Production release
|
Provide utilities to implement bsls_assert and bsls_review .
This component defines a struct
, bsls::AssertImpUtil
, that serves as a namespace for shared functions used by the various handlers provided by bsls_assert and bsls_review .
On some platforms the string constants used to pass filenames to the assert macro invocations are not coalesced, so each inline function use containing such a macro puts an extra copy of the filename string into the resulting executable. For these platforms, it is possible to locally alter the filename that assert macros will use by altering the definition of BSLS_ASSERTIMPUTIL_FILE
.
At the start of your component header, after all other include directives, place the following block of code to detect if this is a platform where the workaround is needed and apply it:
Then, at the end of your header revert the definition of the filename macro to its default:
Finally, in the .cpp
file add the following:
Note that these constants should all be in an appropriate namespace and should have names and contents that match your actual component name.
This section illustrates the intended use of this component.
Suppose you are implementing an assertion handler that should cause a process to terminate when invoked. In order to stop the process immediately, you would call failByAbort
like this:
This function would then abort the current process.
Suppose you want a process to no longer continue doing anything, but you want to leave it running in order to attach a debugger to it and diagnose the full state of your system. In order to have your process sleep forever, you might call failBySleep
like this:
This function would then sleep forever and never return.