Created
September 19, 2009 12:38
-
-
Save qnighy/189476 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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