Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ././../../../../../../usr/man/man3ext/varargs.3ext
Real path: /usr/share/man/man3ext/varargs.3ext
Zurück
'\" te .\" Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. .\" Copyright (c) 1989, AT&T. All rights reserved. .TH varargs 3EXT "10 May 2002" "Oracle Solaris 11.4" "Extended Library Functions" .SH NAME varargs \- handle variable argument list .SH SYNOPSIS .LP .nf #include <varargs.h> va_alist va_dcl va_list \fIpvar\fR; \fBvoid\fR \fBva_start\fR(\fBva_list\fR\fIpvar\fR); .fi .LP .nf \fBtype\fR \fBva_arg\fR(\fBva_list\fR \fIpvar\fR, \fB\fR\fItype\fR); .fi .LP .nf \fBvoid\fR \fBva_end\fR(\fBva_list\fR \fIpvar\fR); .fi .SH DESCRIPTION .sp .LP This set of macros allows portable procedures that accept variable argument lists to be written. Routines that have variable argument lists (such as \fBprintf\fR(3C)) but do not use \fBvarargs\fR are inherently non-portable, as different machines use different argument-passing conventions. .sp .LP \fBva_alist\fR is used as the parameter list in a function header. .sp .LP \fBva_dcl\fR is a declaration for \fBva_alist\fR. No semicolon should follow \fBva_dcl\fR. .sp .LP \fBva_list\fR is a type defined for the variable used to traverse the list. .sp .LP \fBva_start\fR is called to initialize \fBpvar\fR to the beginning of the list. .sp .LP \fBva_arg\fR will return the next argument in the list pointed to by \fBpvar\fR. \fBtype\fR is the type the argument is expected to be. Different types can be mixed, but it is up to the routine to know what type of argument is expected, as it cannot be determined at runtime. .sp .LP \fBva_end\fR is used to clean up. .sp .LP Multiple traversals, each bracketed by \fBva_start\fR and \fBva_end\fR, are possible. .SH EXAMPLES .LP \fBExample 1\fR A sample program. .sp .LP This example is a possible implementation of \fBexecl\fR (see \fBexec\fR(2) ). .sp .in +2 .nf #include <unistd.h> #include <varargs.h> #define MAXARGS 100 /* execl is called by execl(file, arg1, arg2, ..., NULL); */ execl(va_alist) va_dcl { va_list ap; char *file; char *args[MAXARGS]; /* assumed big enough*/ int argno = 0; va_start(ap); file = va_arg(ap, char *); while ((args[argno++] = va_arg(ap, char *)) != 0) ; va_end(ap); return execv(file, args); } .fi .in -2 .sp .SH SEE ALSO .sp .LP \fBexec\fR(2), \fBprintf\fR(3C), \fBvprintf\fR(3C), \fBstdarg\fR(3EXT) .SH NOTES .sp .LP It is up to the calling routine to specify in some manner how many arguments there are, since it is not always possible to determine the number of arguments from the stack frame. For example, \fBexecl\fR is passed a zero pointer to signal the end of the list. \fBprintf\fR can tell how many arguments are there by the format. .sp .LP It is non-portable to specify a second argument of \fBchar\fR, \fBshort\fR, or \fBfloat\fR to \fBva_arg\fR, since arguments seen by the called function are not \fBchar\fR, \fBshort\fR, or \fBfloat\fR. C converts \fBchar\fR and \fBshort\fR arguments to \fBint\fR and converts \fBfloat\fR arguments to \fBdouble\fR before passing them to a function. .sp .LP \fBstdarg\fR is the preferred interface.