Function overloading for ObjC classes
Function overloading for ObjC classes
- Subject: Function overloading for ObjC classes
- From: Allan Odgaard <email@hidden>
- Date: Sun, 22 Feb 2004 07:23:45 +0100
I wanted to write two versions of a function, one for NSData and
another for NSMutableData. Unfortunately the compiler says that I
redefine the same function. Example:
#import <Foundation/Foundation.h>
void foo (NSData* data) { printf("Data\n"); }
void foo (NSMutableData* data) { printf("Mutable Data\n"); }
Output:
In function `void foo(NSMutableData*)':
error: redefinition of `void foo(NSMutableData*)'
error: `void foo(NSData*)' previously defined here
error: redefinition of `void foo(NSMutableData*)'
error: `void foo(NSData*)' previously defined here
If I instead of importing Foundation.h then declare the classes like
this:
@class NSData;
@class NSMutableData;
There are no compiler errors...
I wonder, is this a GCC bug? Overloading does work for "different"
classes (i.e. non sub/super class relationships).
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.