Porting from CFM to Mach-O
I got the source of an extern designed with CodeWarrior, for ppc-s. I
have an Intel Mac, and I don’t have CodeWarrior, but I must make this
extern work somehow, so I thought it’d be a good idea to port it to
XCode. Does anyone have any idea on how to do that? Or is there any
article related to this? I hadn’t found one yet.
+36 (70) 207-63-85
I’m going on with these project quite slow, but now I found an other
problem. The CFM source contains in a point an enum with a tag called
‘time’. When I try to compile the external with this codepart, I’m
getting an error:
error: ‘time’ redeclared as different kind of symbol.
I found out that this is caused because XCode adds somehow automatically
some of the standard C libraries to my includes (I tried for example
that it recognizes the clock() function of time.h without adding any
include in the file), so this enum tag is conflicting with one of the
declarations of the automatically added time.h. How can I tell Xcode not
to do this?
+36 (70) 207-63-85
P C wrote:
> On 8/14/07, Siska Ádám
>> Hello Everyone,
>> I got the source of an extern designed with CodeWarrior, for ppc-s. I
>> have an Intel Mac, and I don’t have CodeWarrior, but I must make this
>> extern work somehow, so I thought it’d be a good idea to port it to
>> XCode. Does anyone have any idea on how to do that? Or is there any
>> article related to this? I hadn’t found one yet.
>> Thank you,
>> Siska Ádám
>> +36 (70) 207-63-85
Re: [dev] Porting from CFM to Mach-O
Quote: Mark Pauley wrote on Thu, 16 August 2007 20:19
> Your best bet is to do:
> #if defined(time)
> #undef time
> or something similar in that source file.
> Personally, I would just change the name of that enum to something
> other than time…
The #ifdef/#undef may or may not work… the precompiler can only handle precompiler stuff, and time.h is probably defining (as opposed to #defining) the word time.
In which case, Adam will have to go through his code and change all references to the enum accordingly. This will probably have to be done manually. Still, even with a few dozen files, it should only take a couple of minutes.
Yes, using C++ namespaces is cleaner, but sometimes keeping code plain-vanilla C is easier.
As for preventing XCode from #including time.h, that’s probably more work that it’s worth. I tried to subvert some of XCode’s auto-includes, but this caused more trouble than it was worth. Apple has deemed a new header file structure as the One True Way. I’m usually not one to be shy of swimming against the stream, but this is one point where it’s a lot easier to just go with the flow.
While you’re here, you will probably have a bunch of "deprecated function call" warnings. Enjoy.
time.h is probably coming the prefix header macho-prefix.pch which includes
So you see it’s not random or haphazard. It’s there because it’s
explicitly included although in a sneaky fashion if you’re not
familiar with these sorts of things.
Forums > Dev