|
18.5.3 Loader Errors
When writing the code to fill out each of the functions needed to
populate the lt_user_dlloader structure, you will often need to
raise an error of some sort. The set of standard errors which might be
raised by the internal module loaders are available for use in your own
loaders, and should be used where possible for the sake of uniformity if
nothing else. On the odd occasion where that is not possible,
libltdl has API calls to register and set your own error
messages, so that users of your module loader will be able to call
lt_dlerror and have the error message you set returned:
- Function: int lt_dlseterror (int errorcode)
- By calling this function with one of the error codes enumerated in the
header file, `ltdl.h',
lt_dlerror will return the associated
diagnostic until the error code is changed again.
- Function: int lt_dladderror (const char *diagnostic)
- Often you will find that the existing error diagnostics do not describe
the failure you have encountered. By using this function you can
register a more suitable diagnostic with libltdl, and subsequently
use the returned integer as an argument to
lt_dlseterror .
libltdl provides several other functions which you may find
useful when writing a custom module loader. These are covered in the
Libtool manual, along with more detailed descriptions of the functions
described in the preceding paragraphs.
In the next chapter, we will discuss the more complex features of
Automake, before moving on to show you how to use those features and add
libltdl module loading to the Sic project from 12. A Large GNU Autotools Project in the chapter after that.
|