0

I have a really old piece of Objective C code as follows:

extern void fncDoSomething(id param); // in Code.h

However when this function is implemented, the developer decided to use Class instead:

void fncDoSomething(Class param) { // in Code.m
// Use param as Class
}

I believe this was accepted in gcc and gobjc's old versions. Is there any flag that allows such code to work?

Info about my environment:

Ubuntu 12.04 GCC 4.6.3

PS: In the source file there's a header with the year 2000.

Edit: I'm running this in a 32-bit Vagrant Box

Edit 2: Here's the actual code and the error message (it appears during compilation):

The error message: FCall.m:591:1: error: conflicting types for 'updateTarget' ./defobj.h:1170:13: note: previous declaration of 'updateTarget' was here

The lines of code:

// FCall.m line 591
void
updateTarget (FCall_c *self, id target)

// defobj.h line 1170
extern void updateTarget (id call, id target);
Robson França
  • 661
  • 8
  • 15
  • It doesn't make a difference.. Just change the implementation parameter to `id`.. `id` is a special keyword that represents an `NSObject` (root of all classes hierarchically) and any message can be sent to it. If however, the developer used DOT notation: `param.blah` instead of `[param blah]`, then you'd have to change it or cast to `Class`. – Brandon Nov 05 '17 at 23:08
  • @Brandon unfortunatelly the developer used dot / arrow notation. – Robson França Nov 05 '17 at 23:11
  • What? On the parameter? How?? That parameter is NOT a pointer so that doesn't seem possible to use arrow notation (dereference -> operator).. Dot notation I understand. Do you have a sample of the code? Perhaps the spot where they used dot notation on the param? – Brandon Nov 05 '17 at 23:12
  • What's the actual issue here? Are you getting a compilation failure? Runtime failure? You should include the error in the content of the question. – Itai Ferber Nov 06 '17 at 03:20
  • A class is an object. if the parameter is a class, change `id` to `Class` else change `Class` to `id`. – Willeke Nov 06 '17 at 14:24

0 Answers0