[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Devel] Re: Strange code in cff/t2parse.c?
From: |
Toby J Sargeant |
Subject: |
Re: [Devel] Re: Strange code in cff/t2parse.c? |
Date: |
Fri, 22 Dec 2000 03:29:16 +1100 |
User-agent: |
Mutt/1.1.9i |
On Thu, Dec 21, 2000 at 10:44:05AM -0500, Tom Kacvinsky wrote:
> Try replacing the code with this:
>
> #define T2_REF( s, f) (FT_UInt)( offsetof( s, f ) )
My reading of the T2_REF macro is that it isn't the same as offsetof; it's
trying to facilitate some simple introspection on structs. the result of
T2_REF is dereferenced structure member which you can use as an argument to
sizeof/typeof etc.
I can't see any way of making this macro palatable to an AS400 compiler.
replacing 0 with NULL might help, as NULL needs to be an already cast
(to void *) pointer, if the compiler is going to whinge badly about casting
an integer to a pointer.
If, on the other hand, it triggers a compiler bug, then you might be a little
stuck. The only thing I can think of (and it's ugly, believe me...)
is to define something like:
#define BEFORE_T2_REF(s) static s _fake_ ## s ;
#define T2_REF(s,f) (_fake_ ## s ## . ## f)
Which will work as follows:
address@hidden $ cpp
#define BEFORE_T2_REF(s) static s _fake_ ## s ;
#define T2_REF(s,f) (_fake_ ## s ## . ## f)
BEFORE_T2_REF(Foo)
T2_REF(Foo,bar)
# 1 ""
static Foo _fake_Foo ;
(_fake_Foo.bar )
... The big problem is that now you need to use the BEFORE_T2_REF macro before
you use the T2_REF macro, and you have to do it in a location where you can
declare variables. YUCK. And doubly yuck when you use T2_REF inside another
macro.
Toby.