public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Stupid typedef question / g++
@ 2003-01-24 15:15 SA
  2003-01-24 16:55 ` Ben Davis
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: SA @ 2003-01-24 15:15 UTC (permalink / raw)
  To: gcc-help


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-01-24 17:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-24 15:15 Stupid typedef question / g++ SA
2003-01-24 16:55 ` Ben Davis
2003-01-24 16:56 ` Sebastian Huber
2003-01-24 17:08 ` John Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).