Hello,
je sèche sur une fonction dans un entête C (linux). Comme c'est la première fois que je fais ça et je ne connais pas le C, je
un peu. Voici la fonction :
extern int get_devices (const Device *** device_list, int local_only);
Ce qui me pose le problème, c'est le 1er paramètre. La doc dit :
stores a pointer to a NULL terminated array of pointers to Device structures in *device_list
. Il me faut donc un pointeur vers un tableau de pointeurs d'enregistrements de type Device. Je ne sais pas trop comment interprérer le "NULL terminated array".
La structure Device en C et la fonction :
1 2 3 4 5 6 7 8 9 10 11
|
typedef const char *String_Const;
typedef struct
{
String_Const name;
String_Const vendor;
String_Const model;
String_Const type;
}
Device; |
ce que je traduis en pascal :
1 2 3 4 5 6 7 8 9 10 11 12 13
| type
String_Const = PChar;
Device = record
name : String_Const;
vendor : String_Const;
model : String_Const;
_type : String_Const;
end;
Device = ^Device;
DeviceArray = array of Device;
PDeviceArray = ^DeviceArray; |
et
1 2 3 4 5
|
function get_devices(
out device_list: PDeviceArray;
local_only : integer)
: integer; cdecl; external External_library; |
Mais j'ai un out of range quand j'accède au tableau et sur ce projet comme beaucoup d'autres le débugeur ne se lance pas :
1 2 3 4 5 6
| var Devicelist: PDeviceArray;
...
get_devices(Devicelist,1);
x := 0;
while Devicelist^[x] <> nil do |
Est-ce que déjà au niveau de l'analyse de la fonction en C ça parait correct ?
Partager