Skip to content

Instantly share code, notes, and snippets.

@qnighy
Created September 19, 2009 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qnighy/189476 to your computer and use it in GitHub Desktop.
Save qnighy/189476 to your computer and use it in GitHub Desktop.
//This source code is for C99
//Pseudo default-argument feature for C99
#include <stdio.h>
#define func(...) func_impl(__VA_ARGS__, -1)
void func_impl(int arg1, int arg2, int arg3, ...);
int main(int argc, char *argv[]);
void func_impl(int arg1, int arg2, int arg3, ...)
{
printf("func() called with argument %d, %d ,%d\n", arg1, arg2, arg3);
}
int main(int argc, char *argv[])
{
//func(1); //error
func(1,2);
func(1,2,3);
func(500, 400);
func(700, 200, 400, 700); //can't be error
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment