Forums > Dev

Porting from CFM to Mach-O

August 15, 2007 | 1:20 am

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,
Adam

________________
Siska Ádám
+36 (70) 207-63-85

http://apocalypse.rulez.org/~sadam


August 15, 2007 | 1:59 am


August 16, 2007 | 3:39 pm

Thank you!

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?

Thank you,
Adam

________________
Siska Ádám
+36 (70) 207-63-85

http://apocalypse.rulez.org/~sadam

P C wrote:
> http://cycling74.com/twiki/bin/view/ProductDocumentation/MaxUBSDK
>
> PC
>
>
> On 8/14/07, Siska Ádám wrote:
>
>> 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,
>> Adam
>>
>>
>> ________________
>> Siska Ádám
>> +36 (70) 207-63-85
>> http://apocalypse.rulez.org/~sadam
>>
>>
>
>
Re: [dev] Porting from CFM to Mach-O


August 16, 2007 | 6:19 pm


August 17, 2007 | 9:46 pm


August 17, 2007 | 10:12 pm


August 17, 2007 | 10:26 pm


August 17, 2007 | 10:51 pm

Quote: Mark Pauley wrote on Thu, 16 August 2007 20:19
—————————————————-
> Your best bet is to do:
>
> #if defined(time)
> #undef time
> #endif
>
> 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.


August 17, 2007 | 11:17 pm

time.h is probably coming the prefix header macho-prefix.pch which includes
#include
#include

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.

wes


August 22, 2007 | 11:03 pm


Viewing 10 posts - 1 through 10 (of 10 total)