Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Let's say we have a function void f(int argc, ...); where argc is the number of variadic arguments. Can we write a macro of the form #define F(...) f(CNT(__VA_ARGS__), __VA_ARGS__) which...
#3: Post edited
- Let's say we have a function
- ```c
- void f(int argc, ...);
- ```
- where `argc` is the number of variadic arguments.
- Can we write a macro of the form
- ```c
#define F(...) f(???, __VA_ARGS__)- ```
- which passes the right value in `argc`?
How can that be implemented?
- Let's say we have a function
- ```c
- void f(int argc, ...);
- ```
- where `argc` is the number of variadic arguments.
- Can we write a macro of the form
- ```c
- #define F(...) f(CNT(__VA_ARGS__), __VA_ARGS__)
- ```
- which passes the right value in `argc`?
- How can that `CNT()` be implemented?
#2: Post edited
- Let's say we have a function
- ```c
- void f(int argc, ...);
- ```
- where `argc` is the number of variadic arguments.
- Can we write a macro of the form
- ```c
#define F(...) fn(???, __VA_ARGS__)- ```
- which passes the right value in `argc`?
- How can that be implemented?
- Let's say we have a function
- ```c
- void f(int argc, ...);
- ```
- where `argc` is the number of variadic arguments.
- Can we write a macro of the form
- ```c
- #define F(...) f(???, __VA_ARGS__)
- ```
- which passes the right value in `argc`?
- How can that be implemented?
#1: Initial revision
Macro to count the number of arguments
Let's say we have a function ```c void f(int argc, ...); ``` where `argc` is the number of variadic arguments. Can we write a macro of the form ```c #define F(...) fn(???, __VA_ARGS__) ``` which passes the right value in `argc`? How can that be implemented?