Stupid typedef question / g++

Fri Jan 24 15:15:00 GMT 2003

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);

// finish

Now I expected the typedefs and casts to enable correct function selection
but what I got was

g++ In function `void test (int)': redefinition of `void test (int)' `void test (int)' previously defined here

Which is what I would expect if I had used 
#define TYPE1 int
#define TYPE2 int

Comments, suggestions? I wanted to use the typedefing to control the function 
calling for elegance in my program.

Thanks SA

More information about the Gcc-help mailing list