[openbeos] Re: How not to actively prevent a PPC version of your software and write better code at the same time

>I'm trying to compile various pieces of OBOS software for PPC. Here are 
>some quick rules that both create better code and make my life a *lot* 
>easier.
>
>1. BEFORE you include your class interface file, do this:
>class _EXPORT MyFooClass.

Ugghh. This is *so* ugly. Isn't this a Metrowerks thing? Does GCC PPC need this?

>2. Please put an _EXPORT before all exported global functions, like 
>this:
>_EXPORT status_t MyFooFunction() {
>       DoSomeStuff();
>}

Ditto.


>3. DON'T put default arguments in the function definition, only in the 
>prototype. Your function will still get the defaults, don't fear.
>       This is okay: void Foo(int i = 4);
>       This is not: void Foo(int i = 4) {}

I 100% agree here - this will not even compile, on some compilers.

>4. Always provide prototypes for non-inline functions. Come on, guys, 
>this is just good practice!

Agreed.

>5. Please (if you are still using makefiles) use the standard Be 
>template. Don't make your own, and especially don't hardcode for gcc. 
>I'll see about making jamfiles work.

Ithamar is going to be moving us all to Jam, shortly. Very shortly. :-)

>That's about it for this rant. Please, please, please, please obey 
>these rules. You will make me very happy, and I might even send you an 
>(e) candy bar.

While PPC is not an intended target, anywhere that we can make their life 
easier without uglifying our code (like 1 & 2 here) is a good thing.


Other related posts: