T. Joseph CarterSun Jun 20 23:33:04 PDT 2004
On Sun, Jun 20, 2004 at 08:50:24PM -0700, Rob Hudson wrote: > I discovered elmo, not the cartoon character, but the mail client: > http://elmo.sourceforge.net/ I thought it might make a nice replacement to > mutt, which I've been using on my server for years. > > I wanted to try it on my FreeBSD server but it dies on the linking stage > saying: > /usr/local/src/elmo-1.2.0/src/str.c(.text+0x28d): undefined reference to `va_copy' > > Do you know what va_copy does? Is it part of C? va_copy is C99. If your libc provides C99 compliance (gcc 3.3 would do it) then you have it with the right thing enabled. va_copy An obvious implementation would have a va_list a pointer to the stack frame of the variadic function. In such a setup (by far the most common) there seems nothing against an assignment va_list aq = ap; Unfortunately, there are also systems that make it an array of pointers (of length 1), and there one needs va_list aq; *aq = *ap; Finally, on systems where parameters are passed in registers, it may be necessary for va_start to allocate memory, store the parameters there, and also an indication of which parameter is next, so that va_arg can step through the list. Now va_end can free the allocated memory again. To accommodate this situation, C99 adds a macro va_copy, so that the above assignment can be replaced by va_list aq; va_copy(aq, ap); ... va_end(aq); Each invocation of va_copy must be matched by a corresponding invocation of va_end in the same function. Some systems that do not supply va_copy have __va_copy instead, since that was the name used in the draft proposal. This is from a Linux system's manpage on the varargs functions. My Mac lacks the manpage, but features the function protected by the explicit need to require C99 be enabled.