32 bit file handles

Ralph Corderoy ralph at inputplus.demon.co.uk
Sun Nov 11 12:46:48 GMT 2001


Hi,

> #define osfind_openin osfind_openinw
> 
> Now, in h.osfind we have:
> 
> extern os_error *xosfind_openin (osfind_flags flags,
>       char const *file_name,
>       char const *path,
>       os_f *file);
> extern os_f osfind_openin (osfind_flags flags,
>       char const *file_name,
>       char const *path);
> 
> So, if that #define is included *before* these prototypes, as it
> would be by DefMod, after name substitution we'd end up with two
> identical prototypes, which I think would be faulted by the compiler.
> Ugh!
> 
> ...
>
> I don't think there is any clever trickery one can play with the
> preprocessor to achieve the correct result.

Howsabout

    #define osfind_openin(flags, file_name, path) \
        osfind_openinw(flags, file_name, path)

then later

    os_f (osfind_openin)(osfind_flags flags, char const *file_name,
        char const *path);

The C preprocessor won't expand `(osfind_openin)' above because it
clearly isn't a invocation of the macro that requires paremeters.  This
is perfectly correct ANSI C.

This is how you typically cope with routines existing as both macros
and functions, e.g. strcmp might be a macro calling a special `inline'
version known about by the compiler but also be prototyped using
(strcmp) to allow for taking its address, etc.

Cheers,


Ralph.




More information about the oslib-team mailing list