我遇到了以下我为gdb运行的错误.这是在运行带有i7处理器的OS X 10.8.5的mac上运行configure之后.
$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --withgxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn
Target: x86_64-apple-darwin12.5.0
Thread model: posix
Run Code Online (Sandbox Code Playgroud)
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12078:18: error: adding 'char' to a string does not append to the string [-Werror,-Wstring-plus-int]
oappend ("%st" + intel_syntax);
~~~~~~^~~~~~~~~~~~~~
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12078:18: note: use array indexing to silence this warning
oappend ("%st" + intel_syntax);
^
& [ ]
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12609:23: error: adding 'char' to a string does not append to the string [-Werror,-Wstring-plus-int]
oappend ("%cs:" + intel_syntax);
~~~~~~~^~~~~~~~~~~~~~
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12609:23: note: use array indexing to silence this warning
oappend ("%cs:" + intel_syntax);
^
& [ ]
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12614:23: error: adding 'char' to a string does not append to the string [-Werror,-Wstring-plus-int]
oappend ("%ds:" + intel_syntax);
~~~~~~~^~~~~~~~~~~~~~
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12614:23: note: use array indexing to silence this warning
oappend ("%ds:" + intel_syntax);
^
& [ ]
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12619:23: error: adding 'char' to a string does not append to the string [-Werror,-Wstring-plus-int]
oappend ("%ss:" + intel_syntax);
~~~~~~~^~~~~~~~~~~~~~
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12619:23: note: use array indexing to silence this warning
oappend ("%ss:" + intel_syntax);
^
& [ ]
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12624:23: error: adding 'char' to a string does not append to the string [-Werror,-Wstring-plus-int]
oappend ("%es:" + intel_syntax);
~~~~~~~^~~~~~~~~~~~~~
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12624:23: note: use array indexing to silence this warning
oappend ("%es:" + intel_syntax);
^
& [ ]
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12629:23: error: adding 'char' to a string does not append to the string [-Werror,-Wstring-plus-int]
oappend ("%fs:" + intel_syntax);
~~~~~~~^~~~~~~~~~~~~~
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12629:23: note: use array indexing to silence this warning
oappend ("%fs:" + intel_syntax);
^
& [ ]
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12634:23: error: adding 'char' to a string does not append to the string [-Werror,-Wstring-plus-int]
oappend ("%gs:" + intel_syntax);
~~~~~~~^~~~~~~~~~~~~~
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:12634:23: note: use array indexing to silence this warning
oappend ("%gs:" + intel_syntax);
^
& [ ]
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:13973:19: error: adding 'char' to a string does not append to the string [-Werror,-Wstring-plus-int]
oappend ("%es:" + intel_syntax);
~~~~~~~^~~~~~~~~~~~~~
/Users/sbala/Downloads/gdb-7.6/opcodes/i386-dis.c:13973:19: note: use array indexing to silence this warning
oappend ("%es:" + intel_syntax);
^
& [ ]
8 errors generated.
make[4]: *** [i386-dis.lo] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-opcodes] Error 2
make: *** [all] Error 2"
Run Code Online (Sandbox Code Playgroud)
如果您需要更多详细信息,请告诉我们.
在OSX上构建gdb-7.6.1时,默认情况下启用了--enable-werror.
./configure --disable-werror
make
Run Code Online (Sandbox Code Playgroud)
对我来说很好.
编译器过于挑剔,因此它会针对涉及字符串文字的指针算法发出警告.此外,您可能配置gdb了--enable-werror或-Werror从某个地方继承,因此这些无害的警告会变成错误.(您只显示了编译器的配置标志,而不是gdb.)
解决方案:-Werror专门使用-Wno-string-plus-int(添加到CFLAGS)关闭或静音此警告