Eric Blake wrote: > > [Moving from m4-patches to bug-gnulib] > > > > [recommendation to run gnulib-tool]
> > Done. Then the linker complained about 'gl_va_copy' being an unresolved > > external. Reason is that va_copy is defined to gl_va_copy in config.h. > > gl_va_copy is supposed to be defined in m4/stdarg.m4. I added gl_STDARG_H > > manually to configure.ac but this didn't help because the gl_STDARG_H > > macro in m4/stdarg.m4 uses the AH_VERBATIM macro with an invalid syntax > > which > > results in a noop. > > More details, please. Adding gl_STDARG_H to configure.ac is wrong; it is > already > added by virtue of the fact that gnulib-tool calls it as part of > M4_EARLY/M4_INIT. > The real question is why ./configure thinks that your compiler doesn't support > va_copy, and what stdarg.m4 should be sticking into config.h that will > work for your compiler. m4/stdarg.m4 contains the following code: ---------------------- if test $gl_cv_func___va_copy = yes; then AC_DEFINE([va_copy], [__va_copy], [Define as a macro for copying va_list variables.]) else AH_VERBATIM([#define gl_va_copy(a,b) (a) = (b)]) AC_DEFINE([va_copy], [gl_va_copy], [Define as a macro for copying va_list variables.]) fi ---------------------- Since $gl_cv_func___va_copy != yes the code after else is executed and "#define va_copy gl_va_copy" is inserted into config.h. Obviously, it is intended to also define gl_va_copy in this case but AH_VERBATIM is called with wrong syntax so that this statement has no effect. The autoconf manual says: ---------------------------- - Macro: AH_VERBATIM (KEY, TEMPLATE) Tell `autoheader' to include the TEMPLATE as-is in the header template file. This TEMPLATE is associated with the KEY, which is used to sort all the different templates and guarantee their uniqueness. It should be a symbol that can be `AC_DEFINE''d. For example: AH_VERBATIM([_GNU_SOURCE], [/* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE #endif]) ---------------------------- So the second argument to AH_VERBATIM which is _empty_ in this case is inserted into config.h ==> it's a noop. Unfortunately, also AH_VERBATIM([_MY_KEY], [#define gl_va_copy(a,b) (a) = (b)]) wouldn't work because (AFAIK) AH_VERBATIM is not expanded at run time (i.e., by configure) but at "compile" time, i.e. by autoheader. This means if bla; then AH_VERBATIM(...) fi and AH_VERBATIM(...) if bla; then fi are 100% identical. Please cc all answers directly to me because I'm not subscribed to the bug-gnulib mailing list. Regards, Andreas