Alignement de bits entre programme Delphi et DLL C++
Bonjour tout le monde,
voilà mon soucis, j'ai une structure que je dois passer à une DLL en C++:
côté Delphi :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
ST_MESS_PARAMS_BUFFER = Packed record
dw_length: DWORD;
by_buffer: BYTE;
end;
ST_MESS_PARAMS = Packed record
by_device_ID : BYTE; // SU ID
by_param_value : BYTE; // RW data
by_family_nb : BYTE; // family number
aby_user_id : TUserIdArray; // user ID on 4 BYTES
dw_num_synchro : DWORD; // synchronization number, for asynchrone call
dw_index_nb : DWORD; // index number of the parameter
dw_SM100IP_ID : DWORD; // SM100 ID
e_state_resp : E_RESP_STATE; // ERROR OR SUCCESS
e_type_param : E_TYPE_PARAM; // type parameter: BYTE, WORD, etc ...
st_params_buffer: ST_MESS_PARAMS_BUFFER;
case Integer of
0:
(
by_value : BYTE;
);
1:
(
w_value : WORD;
);
2:
(
aby_value : ARRAY[0..15] of BYTE // string
);
end; |
et du côté C++:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#pragma pack(push, 1)
typedef struct stMessParamsBuffer
{
unsigned long dw_length;
unsigned char by_buffer;
} ST_MESS_PARAMS_BUFFER;
#pragma pack(pop)
#pragma pack(push, 1)
typedef struct stMessParams
{
unsigned char by_device_ID; // SU ID
unsigned char by_param_value; // RW data
unsigned char by_family_nb; // 0 to 7
unsigned char aby_user_id[USER_ID_HSL]; // user ID on 4 bytes
unsigned long dw_num_synchro; // see information above
unsigned long dw_index_nb; // index number of the parameter
unsigned long dw_SM100IP_ID; // SM100 ID
E_RESP_STATE e_state_resp;
E_TYPE_PARAM e_type_param;
stMessParamsBuffer st_params_buffer;
union Value
{
unsigned char by_value;
unsigned short w_value;
unsigned char aby_value[16]; // string
} value;
} ST_MESS_PARAMS;
#pragma pack(pop) |
Quand je passe ma structure par ma fonction,
Code:
1 2
|
SendParamsSettings(mess_params); |
, du côté C++ j'ai à chaque fois la bonne valeur pour l'enum E_RESP_STATE mais jamais pour E_TYPE_PARAM (il me sort un chiffre au lieu de mon enum).
J'ai l'impression que ça coince lorsque j'utilise plusieurs enum dans un struct :s.
Quelqu'un ai-t-il déjà tombé sur ce problème ?
Merci et bonne journée !