Bonjour,
J'ai un souci de traduction de C vers Delphi:
Voici le code en C (qui marche):
Code c : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
34
35
36
37
38
39
40
41 ... typedef char *IScan_String; .... typedef struct _IScan_ResultConsts { IScan_String IFC_OK; IScan_String IFC_OK_NOT_EXECUTED; IScan_String IFC_OK_DONT_SELL; IScan_String IFC_ERROR_ITEM_UNKNOWN; IScan_String IFC_ERROR_NOT_AN_ITEM; IScan_String IFC_ERROR_IS_COUPON; IScan_String IFC_ERROR_IS_VOUCHER; IScan_String IFC_ERROR_IS_REFUND; IScan_String IFC_ERROR_IS_CUSTOMERCARD; IScan_String IFC_ERROR_IS_GIFTCARD; IScan_String IFC_ERROR_IS_ETOPUP; IScan_String IFC_ERROR_TRY_ALTERNATIVE; IScan_String IFC_ERROR_ILLEGAL_CALL; IScan_String IFC_ERROR_OTHER; IScan_String IFC_PRINT_REPRINT; IScan_String IFC_PRINT_RETRY; IScan_String IFC_PRINT_ABORT; IScan_String IFC_SIGNATURE_ACCEPTED; IScan_String IFC_SIGNATURE_DECLINED; } IScan_ResultConsts; .... LIB_EXPORT const IScan_TextEntryConsts *iscan_constsTextEntry; .... memset (&g_result, 0, sizeof g_result); .... g_result.id = iscan_constsResult->IFC_OK; ...
voici ce que j'ai traduit: (qui ne marche pas):
type
la fonction "iscan_constsResult" me retourne une violation d'accès...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
34
35
36
37
38
39
40
41
42
43
44 IScan_String=PChar; _IScan_ResultConsts = packed record IFC_OK : IScan_String; IFC_OK_NOT_EXECUTED : IScan_String; IFC_OK_DONT_SELL : IScan_String; IFC_ERROR_ITEM_UNKNOWN : IScan_String; IFC_ERROR_NOT_AN_ITEM : IScan_String; IFC_ERROR_IS_COUPON : IScan_String; IFC_ERROR_IS_VOUCHER : IScan_String; IFC_ERROR_IS_REFUND : IScan_String; IFC_ERROR_IS_CUSTOMERCARD : IScan_String; IFC_ERROR_IS_GIFTCARD : IScan_String; IFC_ERROR_IS_ETOPUP : IScan_String; IFC_ERROR_TRY_ALTERNATIVE : IScan_String; IFC_ERROR_ILLEGAL_CALL : IScan_String; IFC_ERROR_OTHER : IScan_String; IFC_PRINT_REPRINT : IScan_String; IFC_PRINT_RETRY : IScan_String; IFC_PRINT_ABORT : IScan_String; IFC_SIGNATURE_ACCEPTED : IScan_String; IFC_SIGNATURE_DECLINED : IScan_String; end; IScan_ResultConsts = _IScan_ResultConsts; PIScan_ResultConsts = ^IScan_ResultConsts; Tiscan_constsResult=function : PIScan_ResultConsts; cdecl; var iscan_constsResult:Tiscan_constsResult; begin // fonction iscan_constsResult appelé dynamiquement getmem(g_result,sizeof(g_result)); FillChar(g_result^, sizeof(g_result), 0); try g_result^.Id:=iscan_constsResult^.IFC_OK; ... finally FreeMem(g_result); end; ... end;
Quelqu'un peut il m'aider ?
Partager