Next: , Previous: , Up: The Macros  


ax_c_referenceable_passed_va_list

Synopsis

AX_C_REFERENCEABLE_PASSED_VA_LIST

Description

Checks whether f(va_list va){ &va; } works as expected.

This macro uses compile-time detection and so is cross-compile ready.

C99 mentioned passing a pointer to va_list to other functions (footnote 212 of "7.15 Variable arguments <stdarg.h>"). However, f(va_list va) { &va; } produces broken pointer on some environments such as gcc on x86_64, although { va_list va; &va; } works as expected. See the detection code of this file and any of pages https://www.gnu.org/software/autoconf/manual/html_node/Function-Portability.html, http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14557, and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20951 for further information.

Although C99 does not define the operations f(va_list va) { &va; } and &va itself as standard (footnotes are declared as "normative part, information only"), certain situations need it. This macro provides a type detection about va_list implementation to deal with the operation.

Following workaround will probably work on such environments although it does not ensure to be safe and portable. At least it is working on x86_64-unknown-linux-gnu:

 f(va_list va)
 {
   va_list *vap;
 #if HAVE_REFERENCEABLE_PASSED_VA_LIST
     vap = &va;
 #else
     vap = (va_list *)va;
 #endif
 }

Source Code

Download the latest version of ax_c_referenceable_passed_va_list.m4 or browse the macro’s revision history.

License

Copyright © 2008 YAMAMOTO Kengo yamaken@bp.iij4u.or.jp

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.