22.2. Reusing Existing Macros

It goes without saying that it makes sense to reuse macros where possible—indeed, a search of the Autoconf macro archive might turn up a macro that does exactly what you want, alleviating the need to write a macro at all (see Section 22.5.1, "Autoconf Macro Archive" ).

It is more likely, however, that you can use generic, parameterized tests to help you get your job done. Autoconf's "generic" tests provide one such collection of macros. A macro that wants to test for support of a new language keyword, for example, should rely on the AC_TRY_COMPILE macro. You can use this macro to attempt to compile a small program and detect a failure resulting from, say, a syntax error.

In any case, it is good practice when reusing ...

Get GNU Autoconf, Automake, and Libtool now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.