1 분 소요

#include
#ifdef _______txt________
함수 호출할때 호출당하는 함수는 인자가 3개인데 호출하는 하는 함수는 인자 두개를
쓸때 과연 될까? 되면 어떻게 되는것일까?
#endif

#define FIRST

//int test(int a, int b, int c);
int test_(int a, int b);

#ifdef FIRST
void test_void(int a, int b, int c);
#else
void test_void_(int a, int b);
#endif

void test_void_bigger_(int a, int b, int c);

//int test2(int a, int b);
#define test(a,b,c) test_(a,b)

#ifdef FIRST
#define test_void_(a,c) test_void(a,b,c)
#else
#define test_void(a, b, c) test_void_(a,c)
#endif //end FIRST

#define test_void_bigger(a,b) test_void_bigger_(a,b,c)

#ifdef _____________define_rule___
define는 보다시피 #define func1() func2()일 경우
fun1()를 실행하면 func2()가 실행된다는것이다.
결국 func1()은 선언되면 안되고 func2()는 미리 선언되어 있어야한다.
#endif

int main(int argc, char *argv[])
{
int a,b,c;

//int c,b,a; // 뒤에서 부터 주소에 입력이된다.

a=1, b=2, c=3;
#ifdef __memory_address_test__
printf(“
%d “,&a);
printf(“
%d “,&b);
printf(“
%d “,&c);
#endif // memory test

#ifdef _memory_address_rule_
inline으로 정의되는 변수들은 뒤의 주소부터 저장된다.
예로 int a,b,c; 하면 &c==68 &b==72 &a==76 이런식으로 저장된다.
#endif

printf(“ %d”,test(a,b,c));

#ifdef FIRST
test_void_(a,c); //==test_void(a,b,c)실행
#else
test_void(a,b,c); //==test_void_(a,b);가 실제로 실행된다.
#endif
test_void_bigger(a,b); //==test_void_bigger_(a,b,c);가 실제로 실행된다.

return 0;
}
/*
int test(int a, int b, int c){
return (a+b) ;
}
*/
int test_(int a, int b){
return (a+b);
}
#ifdef FIRST
void test_void(int a, int b, int c){
printf(“test_void_”);
}
#else
void test_void_(int a, int b){
printf(“
test_void_ %d %d”,a,b);
}
#endif
void test_void_bigger_(int a, int b, int c){ //함수의 변수는 stack에 입력이 된다.

#ifdef _memory_address_rule_
함수에서 받는 변수값의 주소값은 차례대로 정한다. stack(LIFO)로 입력된다
이 함수에서 보면 &a==68 &b==72 &c==76 이런식으로 저장된다.
#endif

printf(“
test_void_bigger %d %d %d “,a,b,c);
printf(“
%d “,&a);
printf(“
%d “,&b);
printf(“
%d “,&c);
}
/*
int test2(int a, int b){
return a+b;
}
*/
#ifdef ________conclusion_________
결국 define으로 함수를 선언하게 mapping시킨다고해도
#define test_void_bigger(a,b) test_void_bigger_(a,b,c)
이것같은 경우 test_void_bigger(a,b)일지라도
실제로는 test_void_bigger_(a,b,c)가 실행이 된다.
#endif
\