मैं उत्सुक हूँ जब इस फ़ाइल संकलन क्यों जीसीसी मुझे दो समान चेतावनी दिखाता है:जीसीसी खराब प्रिंटफ प्रारूप विनिर्देशक के लिए डुप्लिकेट चेतावनी क्यों दिखाता है?
$ clang test.c
test.c:6:14: warning: conversion specifies type 'int' but the argument has type 'long' [-Wformat]
printf("%i\n", foo);
~^ ~~~
%ld
test.c:6:14: warning: conversion specifies type 'int' but the argument has type 'long' [-Wformat]
printf("%i\n", foo);
~^ ~~~
%ld
2 warnings generated.
कोई भी विचार:
$ cat test.c
#include <stdio.h>
int main (int argc, char const *argv[])
{
long foo = 0l;
printf("%i\n", foo);
return 0;
}
$ gcc-4.2 -Wall test.c
test.c: In function ‘main’:
test.c:6: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’
test.c:6: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’
दिलचस्प बात यह है बजना भी दो चेतावनी देता है?
जानकारी के लिए:
$ gcc-4.2 -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/gcc/gcc-5666.3~278/src/configure
--disable-checking --enable-werror --prefix=/usr --mandir=/share/man
--enable-languages=c,objc,c++,obj-c++
--program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib
--build=i686-apple-darwin11 --program-prefix=i686-apple-darwin11-
--host=x86_64-apple-darwin11 --target=i686-apple-darwin11
--with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
$ clang -v
Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.1.0
Thread model: posix
संपादित करें: 'बहु वास्तुकला' परिकल्पना में कुछ सुझाव दिया है अच्छा लग रहा था, लेकिन मुझे यकीन है कि यह सही है नहीं कर रहा हूँ। अगर मैं -arch
के साथ एक एकल आर्किटेक्चर को मजबूर करता हूं, तो मुझे दो चेतावनियां मिलती हैं। अगर मैं -arch x86_64 -arch i386
निर्दिष्ट करता हूं, तो मुझे डुप्लिकेट चेतावनियों के दो सेट मिलते हैं!
$ gcc-4.2 -Wall -arch x86_64 test.c
test.c: In function ‘main’:
test.c:6: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’
test.c:6: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’
$ gcc-4.2 -Wall -arch x86_64 -arch i386 test.c
test.c: In function ‘main’:
test.c:6: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’
test.c:6: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’
test.c: In function ‘main’:
test.c:6: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’
test.c:6: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’
संपादित करें: मैं सब चेतावनी प्रकार के लिए ड्यूप्स नहीं मिलता है। -Wformat
एकमात्र ऐसा है जिसे मैंने अभी तक पार किया है।
$ cat test.c
#include <stdio.h>
int main (int argc, char const *argv[])
{
long foo = 0l;
long bar;
printf("%i\n", foo);
return 0;
}
$ gcc-4.2 -Wall test.c
test.c: In function ‘main’:
test.c:7: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’
test.c:7: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’
test.c:6: warning: unused variable ‘bar’
Fwiw, मैं केवल एक ही त्रुटि संदेश जब मैं जीसीसी 4.1.2 का उपयोग मिलता है । क्या आप वाकई अपने निर्माण प्रणाली का आर्टिफैक्ट नहीं हैं, जो किसी भी तरह से जीसीसी को दो बार आमंत्रित कर रहा है? –
धन्यवाद ओली। मुझे यकीन नहीं है, शायद यह है।: -/ –
मुझे डुप्लिकेट चेतावनी नहीं दिखाई दे रहा है। लेकिन फिर, यह एक चेतावनी है कि आपको वैसे भी ठीक करना चाहिए, इसलिए ... –