[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] MiNTLib 0.51
Guido Flohr wrote:
> > If a prototype is declared Pure C applies implicit coercions to
> > passed arguments.
>
> Is it ok if I explicitely typecast all pointers to long?
Technically, hmmmm, tja, hmmmmmmmmmmmmmm, perhaps? hmmm errrrmmmm.
You could also go programming in Basic. :-)
> It's not forgotten, it's wrong on purpose (see explanation in other mail).
> However, I see, that this will need more work to get it to run with PureC.
I understood that, and was not referring to that particular case.
> What if all affected functions would be marked as "cdecl" in the header
> files? For gcc "cdecl" could be #define'd to the empty string and PureC
> should know that it has to pass all arguments on the stack.
Cdecl is part of Pure C to be able to interact or interface with subsystems
not compiled with Pure C. You see it mainly used in interaction with a OS.
Use it selectively.
> Performance is not such a big deal because most of these functions do I/O
> and the little overhead can be ignored when compared to the filesystem
> activity.
Good programming practice should always prevail.
Comfortably in bed, book laid aside and not yet sleeping, I reflected what I wrote.
I concluded that I didnt express myself very to the point.
May be the following is a better story (more generalized):
If prototyping is not used for *ALL* functions, you probably will suppress
a 'no prototype' kind of warning. If you have done that, you can loose a prototype
inadvertently without noticing. This happens for instance when you move functions
to other files, or introduce name conventions so names change. In general when
one does some reorganization.
The coercions I described are are generated silently by Pure C.
The danger is: when you loose a prototype without noticing, YOU ALSO LOOSE these
coercions without noticing, and the function is called wrongly.
Suddenly, functions that have performed well for years, are now failing, without
a single byte changed in them.
My advice is: Use either no prototypes at all and watch carefully all call's,
or be strict on prototyping and let the compiler warn you, or better: error you.
Do for functions the same as for variable's: declare in advance.
Regards
Henk.