Bradford Fisher
Bradford Fisher

Reputation: 141

Validating Variable Length Arguments

Is it possible to verify the type and number of arguments supplied to a variable length argument? (...)?

Upvotes: 0

Views: 101

Answers (1)

William Morris
William Morris

Reputation: 3684

At runtime? The type, no. The number, only if the caller places a NULL (or something recognisable) at the end, which is unreliable.

At compile time, you can get the compiler to check the arguments in the same way that it will check the args to printf. Google for gcc __attribute__ format

Upvotes: 1

Related Questions