API problem: sizeof(struct)<>size(GROUP)? 
Author Message
 API problem: sizeof(struct)<>size(GROUP)?

Hi API Gurus,

I'm having problems interfacing the windows API when using groups.
Obviously "C" structure memory sizes are different from clarion
group memory sizes as determined by "sizeof" resp. "size" functions.
I suspect this may have to do with alignment issues, but I'm not
sure about that.

Example:

RAS_MaxDeviceName =128
RAS_MaxDeviceType   =6

"C" structure

typedef struct _RASCONNSTATUS

    DWORD         dwSize;
    RASCONNSTATE  rasconnstate;          <-- a "long" enumeration
    DWORD         dwError;
    CHAR          szDeviceType[RAS_MaxDeviceType + 1];
    CHAR          szDeviceName[RAS_MaxDeviceName + 1];

Quote:
} RASCONNSTATUS;

----> sizeof(RASCONNSTATUS) returns 160

I have converted that structure to the following clarion group:

RASCONNSTATUS GROUP, TYPE
dwSize        ULONG
rasconnstate  ULONG
dwError       ULONG
szDeviceType  CSTRING(RAS_MaxDeviceType + 1)
szDeviceName  CSTRING(RAS_MaxDeviceName + 1)
          END

----> size(RASCONNSTATUS) returns 158.

If the C structure was 2-byte alligned, the szDeviceType and szDeviceName
would both be padded with an extra byte, thus the difference (my
assumption).

What can I do to make the clarion group "C" compatible (besides of adding
extra bytes manually?)

Any insights appreciated,
Jens



Fri, 24 Jan 2003 03:00:00 GMT  
 API problem: sizeof(struct)<>size(GROUP)?
Use STRING instead of CSTRING.

--
Lee White, TeamVelocity
Lodestar Software: www.CWaddons.com
DeveloperPLUS, your source for tools and services: www.DeveloperPLUS.com


Quote:
> Hi API Gurus,

> I'm having problems interfacing the windows API when using groups.
> Obviously "C" structure memory sizes are different from clarion
> group memory sizes as determined by "sizeof" resp. "size" functions.
> I suspect this may have to do with alignment issues, but I'm not
> sure about that.



Fri, 24 Jan 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ><><><><>Heeeeeeeeeeeeeeelp on INT 14!><><><><><>

2. <<<<<YOU MUST CHECK THIS OUT >>>>>>>>>> 2103

3. <><><> FLOODFILL <><><>

4. >>>HELP, DECOMPILER<<<

5. <<<XXX Password>>>

6. >>>>>>>>>>>>>>>>>>>HEY!<<<<<<<<<<<<<<<<<<<<<<<

7. <<<XXX Password>>>

8. ??? <<<<<<<<<<<<<<<<<<<< RGB 4 MMX >>>>>>>>>>>>>>>>>>>>>>>?

9. <<<XXX Password>>>

10. ??? <<<<<<<<<<<<<<<<<<<< RGB 4 MMX >>>>>>>>>>>>>>>>>>>>>>>?

11. DataEase problem - <Argh><HELP!>

 

 
Powered by phpBB® Forum Software