symbol.c: En fonction 'symbol_FPrint':j'avoir avertissement suivant dans la compilation gcc en architecture 32 bits, mais ne pas avoir un tel avertissement dans l'architecture 64 bits
symbol.c:1209: warning: format '%ld' expects type 'long int', but argument 3 has type 'SYMBOL'
symbol.c: In function 'symbol_FPrintOtter':
symbol.c:1236: warning: format '%ld' expects type 'long int', but argument 3 has type 'SYMBOL'
symbol.c:1239: warning: format '%ld' expects type 'long int', but argument 3 has type 'SYMBOL'
symbol.c:1243: warning: format '%ld' expects type 'long int', but argument 3 has type 'SYMBOL'
symbol.c:1266: warning: format '%ld' expects type 'long int', but argument 3 has type 'SYMBOL'
Dans symbol.c
1198 #ifdef CHECK
1199 else {
1200 misc_StartErrorReport();
1201 misc_ErrorReport("\n In symbol_FPrint: Cannot print symbol.\n");
1202 misc_FinishErrorReport();
1203 }
1204 #endif
1205 }
1206 else if (symbol_SignatureExists())
1207 fputs(symbol_Name(Symbol), File);
1208 else
1209 fprintf(File, "%ld", Symbol);
1210 }
et le symbole est défini comme:
typedef size_t SYMBOL
Lorsque j'ai remplacé '% ld' avec '% zu', j'ai eu l'avertissement suivant:
symbol.c: In function 'symbol_FPrint':
symbol.c:1209: warning: ISO C90 does not support the 'z' printf length modifier
Note: De là, il a été modifié le 26 mars 2010 et problème suivant et a ajouté beeen en raison de sa similitude avec le problème mentionné ci-dessus.
J'ai déclaration suivante:
printf("\n\t %4d:%4d:%4d:%4d:%4d:%s:%d", Index, S->info, S->weight,
Precedence[Index],S->props,S->name, S->length);
L'avertissement que je reçois lors de la compilation en architecture 64 bits est:
format ‘%4d’ expects type ‘int’, but argument 5 has type ‘size_t’
voici les définitions des paramètres:
NAT props;
typedef unsigned int NAT;
Comment puis-je me débarrasser de cela afin que je puisse compiler sans avertissement dans l'architecture 32 et 64 bits?
Quelle peut être sa solution?
qui a vraiment fonctionné pour les deux, j'ai encore un nouvel avertissement sur la même ligne 0e ISO C90 ne supporte pas le modificateur de longueur gnu_printf 'z'. Quelles peuvent être les alternatives dans ce cas? – thetna
Utilisez soit -std = c99 lorsque vous compilez, soit # define un spécificateur de format, par ex. 'FMT_SIZE_T' qui est # défini comme'% llu' sur les versions 64 bits et '% lu' sur les versions 32 bits. –
merci beaucoup Paul.Il a vraiment travaillé. – thetna