Revision history for KeyPgVaArg


Revision [22612]

Last edited on 2019-03-10 14:14:02 by JeffMarshall [update with cva_* functions and links]
Additions:
Not supported when using ##[[CompilerOptgen|-gen gcc]]##. Use ##[[KeyPgCvaList|cva_list]]## variadic argument list type for cross platform compatibility.
Deletions:
//Note:// Not supported when using gcc.


Revision [21513]

Edited on 2016-07-25 16:07:09 by fxm [Little rewording for more clarity.]
Additions:
The ##**va_arg**## macro allows the use of a variable number of arguments within a function:
- ##**va_arg**## returns the current argument in the list, ##//argument_list//##, with an expected data type of ##//datatype//##.
- Before first ##**va_arg**## use, ##//argument_list//## must be initialized with the command ##[[KeyPgVaFirst|va_first]]##.
- Unlike the C macro with the same name, ##**va_arg**## does not automatically increment ##//argument_list//## to the next argument within the list. Instead ##[[KeyPgVaNext|va_next]]## must be used to find the next argument in adjusting ##//argument_list//##.
Deletions:
The ##**va_arg**## macro allows the use of a variable number of arguments within a function. ##**va_arg**## returns the current argument in the list, ##//argument_list//##, with an expected data type of ##//datatype//##. Before ##**va_arg**## can be used, it must be Initialized with the command ##[[KeyPgVaFirst|va_first]]##. Unlike the C macro with the same name, ##**va_arg**## does not automatically increment ##//argument_list//## to the next argument within the list. Instead ##[[KeyPgVaNext|va_next]]## must be used to find the next argument.


Revision [21268]

Edited on 2016-03-18 08:43:45 by fxm [Not supported when using gcc]
Additions:

//Note:// Not supported when using gcc.


Revision [20577]

Edited on 2016-02-10 16:10:14 by DkLwikki [Update link format]
Additions:
//variable// = **va_arg** ( //argument_list//, [[DataType|datatype]] )
The ##**va_arg**## macro allows the use of a variable number of arguments within a function. ##**va_arg**## returns the current argument in the list, ##//argument_list//##, with an expected data type of ##//datatype//##. Before ##**va_arg**## can be used, it must be Initialized with the command ##[[KeyPgVaFirst|va_first]]##. Unlike the C macro with the same name, ##**va_arg**## does not automatically increment ##//argument_list//## to the next argument within the list. Instead ##[[KeyPgVaNext|va_next]]## must be used to find the next argument.
See the ##[[KeyPgVaFirst|va_first()]]## examples.
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__va_arg""**##.
- ##[[KeyPgDots|... (Ellipsis)]]##
- ##[[KeyPgVaFirst|va_first]]##
- ##[[KeyPgVaNext|va_next]]##
Deletions:
//variable// = **va_arg** ( //argument_list//, [[DataType datatype]] )
The ##**va_arg**## macro allows the use of a variable number of arguments within a function. ##**va_arg**## returns the current argument in the list, ##//argument_list//##, with an expected data type of ##//datatype//##. Before ##**va_arg**## can be used, it must be Initialized with the command ##[[KeyPgVaFirst va_first]]##. Unlike the C macro with the same name, ##**va_arg**## does not automatically increment ##//argument_list//## to the next argument within the list. Instead ##[[KeyPgVaNext va_next]]## must be used to find the next argument.
See the ##[[KeyPgVaFirst va_first()]]## examples.
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__va_arg""**##.
- ##[[KeyPgDots ... (Ellipsis)]]##
- ##[[KeyPgVaFirst va_first]]##
- ##[[KeyPgVaNext va_next]]##


Revision [16667]

Edited on 2013-03-22 15:07:51 by CountingPine [Update link format]
Additions:
The ##**va_arg**## macro allows the use of a variable number of arguments within a function. ##**va_arg**## returns the current argument in the list, ##//argument_list//##, with an expected data type of ##//datatype//##. Before ##**va_arg**## can be used, it must be Initialized with the command ##[[KeyPgVaFirst va_first]]##. Unlike the C macro with the same name, ##**va_arg**## does not automatically increment ##//argument_list//## to the next argument within the list. Instead ##[[KeyPgVaNext va_next]]## must be used to find the next argument.
Deletions:
The ##**va_arg**## macro allows the use of a variable number of arguments within a function. ##**va_arg**## returns the current argument in the list, ##//argument_list//##, with an expected data type of ##//datatype//##. Before ##**va_arg**## can be used, it must be Initialized with the command ##[[KeyPgVaFirst va_first]]##. Unlike the C macro with the same name, ##**va_arg**## does not automatically increment ##//argument_list//## to the next argument within the list. The command ##[[KeyPgVaNext va_next]]## must be used for this purpose.


Revision [15315]

Edited on 2011-10-01 10:09:40 by DkLwikki [Point to KeyPgVaFirst instead of duplicating]
Additions:
See the ##[[KeyPgVaFirst va_first()]]## examples.
Deletions:
{{fbdoc item="filename" value="examples/manual/procs/va_arg.bas"}}%%(freebasic)
' Note that CDECL is used here --> it must be used with an ellipsis argument (...).
FUNCTION Avg cdecl (Count as INTEGER, ... ) AS DOUBLE
DIM ARG AS ANY PTR
DIM SUM AS DOUBLE = 0
DIM i AS INTEGER

ARG = VA_FIRST()
FOR i = 1 TO COUNT
SUM += VA_ARG(ARG, DOUBLE)
ARG = VA_NEXT(ARG,DOUBLE)
NEXT i
RETURN SUM/COUNT
end function
PRINT AVG (4, 3.4,5.0,3.2,4.1)
PRINT AVG (2, 65.2,454.65481)
SLEEP
%%
The output would look like:
%%
3.925
259.927405
%%


Revision [15009]

Edited on 2010-12-13 16:12:06 by AgAmemnus [Point to KeyPgVaFirst instead of duplicating]
Additions:
Returns the current argument from a variable argument list.
' Note that CDECL is used here --> it must be used with an ellipsis argument (...).
Deletions:
Returns the current argument from a variable argument list


Revision [14462]

Edited on 2009-08-29 21:57:34 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
- New to ""FreeBASIC""
Deletions:
- New to FreeBASIC


Revision [13196]

The oldest known version of this page was created on 2008-04-24 15:44:58 by JeffMarshall [Remove CamelCase links in "New to FreeBASIC"]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode