Re: Help! GPF

new topic     » goto parent     » topic index » view thread      » older message » newer message

Bernie Ryan writes:
> It should be AppendMenuA
>          { C_LONG, C_UINT, C_UINT,C_POINTER } C_INT
>
> The first parameter you defined as a C_POINTER
> ( the menu handle ) It should be a C_LONG because
> Rob handles a C_POINTER different than a C_LONG
> internally. It may cause a problem if the handle is a certain
> value and this maybe what is causing the GPF's.

As far as passing values to a C routine is concerned,
C_LONG, C_POINTER and all other integer types
are *all equivalent*.

It *doesn't matter* how you declare the parameters
in your define_c_proc() or define_c_func() statement.
In WIN32, all C integer types, from 1 byte to 4 bytes in size
are pushed onto the call stack as a generic 4-byte quantity.
It's up to receiver of the value to interpret it as a signed
or unsigned value, a pointer, or whatever.
(C_DOUBLE is different - Euphoria will push an 8-byte
floating-point number onto the stack.)

There *is* a difference between signed and unsigned
integers, but only when you declare the *return-type*
in define_c_func(). It can affect whether you get a negative
integer or a large positive integer returned from c_func().

Why have so many different C types when they are mostly
all equivalent?

    1. Maybe some extra warnings could be added in the
         compiler, or in safe.e to flag obvious cases where
         you are passing a value that is not consistent with
         the C parameter type. e.g. you declared a parameter
         as C_UINT, but you are passing a negative value.

    2. On other platforms, things might be passed
         differently, e.g. chars might be passed differently
         from longs, or maybe pointers are 8 bytes, not 4.
         The interpreter would need to know the exact type.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://members.aol.com/FilesEu/

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu