We are happy to announce that we will begin providing error-handling sources with our optimized runtime libraries in forthcoming versions of ASN1C. Optimized runtime libraries omit the error handling messages and stack traces that help users to debug applications in a non-optimized context. This functionality comes at a performance and size cost that may not be appropriate for many applications in the field, but we have recently received several requests to make errors more explicit.
To that end, we are providing source files with our distribution that contain implementations of the runtime error handling functions as well as the error tables. To demonstrate how to use these, let's briefly look at some examples.
Optimized Libraries without Error Handling
The first example is to show what happens if we attempt to decode a faulty PersonnelRecord from our c/sample_ber/employee sample program. We have modified the data so that the message ends unexpectedly, and the following output occurs:
$ ./reader ERROR: Status -101 unrecognized completion status
We would like to provide a more descriptive message if possible to the user.
Compiling the Error Handling Sources
We begin by compiling the provided error handling sources:
$ gcc -c -O3 -I /path/to/asn1c berError.c $ gcc -c -O3 -I /path/to/asn1c rtxError.c
While we show a gcc compilation here, it would not be terribly different if we were using Visual Studio: either replacing gcc with cl or adding the given sources to the Visual Studio project will do the trick.