Previous: , Up: Notes   [Contents][Index]


C.6 Compatibility For Old Extensions

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 gawk provided an extension mechanism that required knowledge of gawk 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 release.

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 routines (dl_load() versus dlload()), they may safely be installed in the same directory (to be found by AWKLIBPATH) without conflict.

The gawk development team strongly recommends that you convert any old extensions that you may have to use the new API described in Dynamic Extensions.