Kbase P7765: Example about correspondence between Progress and C variables (structures)
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/10/2008 |
|
Status: Verified
GOAL:
Example about correspondence between Progress and C variables (structures)
FIX:
C:
typedef struct b {
int a1;
char b1;
} str_B;
typedef struct c {
int a2;
char b2;
} str_C;
typedef struct a {
str_B struct_field;
int int_field;
str_C struct_field_2;
} astruct;
Then this is how you would pass a structure of type astruct to a dll:
DEFINE SHARED VAR STR_x AS MEMPTR.
/* size of str_B is: an int (4 bytes) plus a char (1 byte), total 5 bytes */
/* size of str_B is also 5 bytes (one int and one char) */
SET-SIZE(STR_x)= 5 /* size of str_B */
+ 4 /* size of int (a long integer is 4 bytes) */
+ 5. /* size of str_C */
PUT-LONG(STR_x,1)=23. /* fill a1 */
PUT-BYTE(STR_x,5)="A". /* fill a2 */
PUT-LONG(STR_x,6)=44. /* fill int_field */