Dynamic Extensions, describes the supported API and mechanisms
for writing extensions for
gawk. This API was introduced
in version 4.1. However, for many years
provided an extension mechanism that required knowledge of
internals and that was not as well designed.
In order to provide a transition period,
gawk version 4.1
continues to support the original extension mechanism.
This will be true for the life of exactly one major release. This support
will be withdrawn, and removed from the source code, at the next major
Briefly, original-style extensions should be compiled by including the awk.h header file in the extension source code. Additionally, you must define the identifier ‘GAWK’ when building (use ‘-DGAWK’ with Unix-style compilers). Otherwise, the definitions in gawkapi.h will cause conflicts with those in awk.h and your extension will not compile.
Just as in previous versions, you load an old-style extension with the
extension() built-in function (which is not otherwise documented).
This function in turn finds and loads the shared object file containing
the extension and calls its
dl_load() C routine.
Because original-style and new-style extensions use different initialization
dlload()), they may safely
be installed in the same directory (to be found by
gawk development team strongly recommends that you
convert any old extensions that you may have to use the new API
described in Dynamic Extensions.