Re: define carbon constant in lisp
On Tuesday 08 June 2004 01:15 pm, Stefano R Bonissone wrote:
....
> I tried to create the appropriate SInt8 type (which is a signed char) to
> represent it, but still couldn't find a way to pass it fsRdPerm (0x100)
The 0x100 is a typo, right? The man page says that fsRdPerm is 0x01.
Signed char means a value between -128 and +127. 0x100 is +256.
> without it erroring out. It either errors with a bus error when I pass it
> a value of 1, or cannot convert it to the foreign type error when I try
> other things.
Bus error often means that the code is accessing incorrectly aligned data.
Many C compilers stretch parameters to be the same size as an address (void*)
before pushing them onto the stack. Some operating systems (e.g. Windows)
also impose non-C parameter conventions. If you know what the Carbon C
compiler does, you could guess how to lie to the fli (see below).
C is a sloppy language with sloppy "strong" typing added to it as an
afterthought. If you want to work around your problem - until davef responds
with more accuracy than I - just lie to the fli. Try telling it that
"permission" is a :byte, or a :short, or a :long and see which one works.
> The enum which defines the constants, including fsRdPerm, is not typed, so
No, it is typed - by some sort of (obscure) default. You probably have to
poke around the C standard to see how enums are defined to be typed when a
type is not explicitly specified by the programmer (e.g. is the compiler
allowed to compress the enum to fit into the smallest number of byte-aligned
bits, or, does it default to "int" like many other things in C do?).
pt