freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Devel] Re: Strange code in cff/t2parse.c?


From: Tom Kacvinsky
Subject: [Devel] Re: Strange code in cff/t2parse.c?
Date: Thu, 21 Dec 2000 10:44:05 -0500 (EST)

This has been fixed in the current code.  The macro T2_REF (which was
meant to access a field in a struct) has been replaced by a macro that
resolves to use of the ANSI standard offsetof() function.

I cannot find anything in my C books about such contructs as ((s*)0)->f, but my
general impression is that it means if the 0 pointer were cast to a pointer to
struct s, and the we accessed struct member f, we would then have an offset from
0, which is the offset from the beginning of the struct to member f.

Try replacing the code with this:

#define T2_REF( s, f) (FT_UInt)( offsetof( s, f ) )

And see how you fare...

Regards,

Tom

On Thu, 21 Dec 2000, Rich Stephens wrote:

> Hello all...
>
> We're attempting to do something a bit odd....compile freetype on an AS400.
> We're using freetype 2, beta 8.  Yes, I know I should get the latest code,
> but we need to get our platforms in sync with the same version before we
> start updating.  Our problem at present is the following odd bit of code,
> specifically the first line here I show, in src/cff/t2parse.c.  Lines 408
> and 409 below it show an example of this odd macro in use:
>
>     +392  #define T2_REF( s, f )  ( ((s*)0)->f )
>   +393
>   +394  #define T2_FIELD_CALLBACK( code, name ) \
>   +395            {                             \
>   +396              t2_kind_callback,           \
>   +397              code | T2CODE,              \
>   +398              0, 0,                       \
>   +399              parse_ ## name,             \
>   +400              0, 0                        \
>   +401            },
>   +402
>   +403  #undef  T2_FIELD
>   +404  #define T2_FIELD( code, name, kind )                 \
>   +405            {                                          \
>   +406              kind,                                    \
>   +407              code | T2CODE,                           \
>   +408              (FT_UInt)(char*)&T2_REF( T2TYPE, name ), \
>   +409              sizeof( T2_REF( T2TYPE, name ) ),        \
>   +410              0, 0, 0                                  \
>   +411            },
>
> Our compiler on the AS400 chokes on line 392 big-time, and I am at a loss as
> to exactly its purpose.  How is taking a reference to a member of a
> structure pointer whose value is 0 valid on ANY platform?  I know, it
> compiles on our UNIX platforms, but I can't see for sure why...what IS it,
> and is there any way to change the macro to make it less... wierd (I.E. so
> it will compile on our AS400)?
>
> Rich Stephens
> Software Developer
>
> Optio Software, Inc.
> Windward Fairways II
> 3015 Windward Plaza
> Alpharetta, GA 30005
> (770) 576-3561
> address@hidden
>
>
> _______________________________________________
> Devel mailing list
> address@hidden
> http://www.freetype.org/mailman/listinfo/devel
>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]