This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Stupid typedef question / g++
- From: SA <bullet dot train at ntlworld dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 24 Jan 2003 15:17:27 +0000
- Subject: Stupid typedef question / g++
Should this work?
// start
#include <stdio.h>
typedef int TYPE1;
typedef int TYPE2;
void test(TYPE1);
void test(TYPE2);
void test(TYPE1 in){
printf("Called via type1 %d\n",(int)in);
}
void test(TYPE2 in){
printf("Called vis type2 %d\n",(int)in);
}
main(){
test((TYPE1)10);
test((TYPE2)20);
}
// finish
Now I expected the typedefs and casts to enable correct function selection
but what I got was
g++ test.cc
test.cc: In function `void test (int)':
test.cc:12: redefinition of `void test (int)'
test.cc:8: `void test (int)' previously defined here
Which is what I would expect if I had used
#define TYPE1 int
#define TYPE2 int
instead?
Comments, suggestions? I wanted to use the typedefing to control the function
calling for elegance in my program.
Thanks SA