本文介绍了奇怪的海湾合作委员会错误:在程序中散布'\NNN'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下问题在我的开源库中弹出,我无法弄清楚发生了什么。
我的两个用户有(gcc)编译器错误看起来像:
/ home / someone / Source / src /._ regex.cpp:1:1:warning:null character (s)忽略
/home/someone/Source/src/._regex.cpp:1:错误:在程序
/home/someone/Source/src/._regex中输入'\ 5'。在程序
/home/someone/Source/src/._regex.cpp:1:错误:程序
/ home中出现'\ 7'错误:cpp:1:error:stray'\26' /someone/Source/src/._regex.cpp:1:5:警告:忽略空字符
/home/someone/Source/src/._regex.cpp:1:错误:发生错误'\ 2'in program
...
我无法重现这些错误;代码在我测试过的所有机器上编译得很好。
谷歌搜索似乎表明这通常是奇怪的编码或奇怪的格式化的结果,但我跑了所有通过十六进制编辑器来源,并且所有字符都是可打印的ASCII(0x20 - 0x7E),或制表符或换行符。就是这样。
另外,两位用户都成功编译了以前版本的库;但是从那时起,特定的文件( regex.cpp
)及其头文件还没有被修改!
此处了解更多详情,包括链接如果你想要下载代码。但我会很高兴只是一个指向可能的方向。 解决方案 Baffe Boyois得到了正确的答案 - 你的CMake规则必须做得太多。
在MacOS X 10.5.8(Leopard)上,我得到:
Osiris JL:cmake ..
- C编译器标识符是GNU
- CXX编译器标识符是GNU
- 检查工作C编译器:/ usr / bin / gcc
- 检查工作的C编译器:/ usr / bin / gcc - works
- 检测C编译器ABI信息
- 检测C编译器ABI info - done
- 检查工作CXX编译器:/ usr / bin / c ++
- 检查工作CXX编译器:/ usr / bin / c ++ - works
- 检测CXX编译器ABI info
- 检测CXX编译器ABI信息 - 完成
- 配置完成
- 生成完成$ b $ - 生成文件已写入:/ Users / jleffler / tmp / yaml-cpp-0.2.3 / build
Osiris JL:make
扫描目标yaml-cpp的相关性
[ 2%] Building CXX object CMakeFiles / yaml-cpp.dir / src /._ conversion.cpp.o
/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1:1:warning:空字符忽略
/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1:错误:在程序
/ tmp / yaml-cpp中丢失'\ 5' -0.2.3 / src /._ conversion.cpp:1:错误:在程序
中丢失'\22'/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1:错误:在程序
/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1:5中忽略'\7':警告:忽略空字符
/ tmp / yaml -cpp-0.2.3 / src /._ conversion.cpp:1:错误:在程序
中丢失'\ 2'/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1: 7:警告:忽略空字符
/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1:17:警告:空字符忽略
.. 。
你应该列出你需要编译的文件;你不应该只是编译所有和杂项。
这个问题似乎在CMakeLists.txt中:
<$ p $ (GLOB来源src / *。cpp)
文件(GLOB public_headers include / *。h)
文件(GLOB private_headers src / *。h)
文件
CMake GLOB有点过于热情(我使用的是2.6版本的补丁4),或者你承担不起在您的任何客户使用MacOS X时使用它。
GLOB正在扩展以包含以'。'开头的文件是任何人的猜测;但是,作为一种解决方法,我编辑了CMakeLists.txt并使其工作:
(GLOB public_headers include / [az] *。h)
file(GLOB private_headers src / [az] *。h)
文件(GLOB来源src / [az] *。cpp)
这不是完整的解决方案:我用yaml-reader目录中的代码解决了问题的延续。我以基本相同的方式修改了yaml-reader / CMakeLists.txt文件。
FWIW:
$ file ._ *
._conversion.cpp:AppleDouble编码的Macintosh文件
._exp.cpp:AppleDouble编码的Macintosh文件
._map.cpp:AppleDouble编码Macintosh文件
._map.h:AppleDouble编码的Macintosh文件
._node.cpp:AppleDouble编码的Macintosh文件
._null.cpp:AppleDouble编码的Macintosh文件
._ostream.cpp: AppleDouble编码的Macintosh文件
._parser.cpp:AppleDouble编码的Macintosh文件
._regex.cpp:AppleDouble编码的Macintosh文件
._regeximpl.h:AppleDouble编码的Macintosh文件
._scanner。 cpp:AppleDouble编码的Macintosh文件
._scanner.h:AppleDouble编码的Macintosh文件
._scanscalar.cpp:AppleDouble编码的Macintosh文件
._scanscalar.h:AppleDouble编码的Macintosh文件
。 _sequence.cpp:AppleDouble编码的Macintosh文件
._simplekey.cpp:AppleDouble编码的Macintosh文件
._stream.cpp:AppleDouble编码的Macintosh文件
._token.h:AppleDouble编码的Macintosh文件
$ odx ._con *。 cpp
0x0000:00 05 16 07 00 02 00 00 4D 61 63 20 4F 53 20 58 ........ Mac OS X
0x0010:20 20 20 20 20 20 20 20 00 02 00 00 00 09 00 00 ........
0x0020:00 32 00 00 00 79 00 00 00 02 00 00 00 AB 00 00.2 ... y ........ ..
0x0030:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
*
0x0050 :00 00 00 41 54 54 52 00 3C E0 2B 00 00 00 AB .... ATTR。 0x0060:00 00 00 9C 00 00 00 0F 00 00 00 00 00 00 00 00 ................
0x0070:00 00 00 00 00 00 00 01 00 00 00 9C 00 00 00 0F ......... .......
0x0080:00 00 17 63 6F 6D 2E 61 70 70 6C 65 2E 54 65 78 ... com.apple.Tex
0x0090:74 45 6E 63 6F 64 69 6E 67 00 00 00 55 54 46 2D tEncoding ... UTF-
0x00A0:38 3B 31 33 34 32 31 37 39 38 34 8; 13 4217984
0x00AB:
$
一个奇怪的细节 - 'src'目录没有影子文件。当我执行'tar -tvf yaml-cpp-0.2.3.tar.gz'时,我会看到随源提供的文件:
Osiris JL:tar -tvf yaml-cpp-0.2.3.tar.gz
drwxr-xr-x beder / staff 0 2009-10-22 15:13:52 ./
-rw-r - r-- beder / staff 1750 2009-10-22 15:09:05 ./CMakeLists.txt
drwxr-xr-x beder / staff 0 2009-10-19 16:40: 15 ./include/
-rw-r - r-- beder / staff 171 2009-09-06 13:41:54 ./include/._conversion.h
-rw-r-- r-- beder / staff 1118 2009-09-06 13:41:54 ./include/conversion.h
-rw-r - r-- beder / staff 302 2009-07-29 15:25: 23 ./include/crt.h
-rw-r - r-- beder / staff 2254 2009-10-19 16:40:14 ./include/emitter.h
-rw-r --r-- beder / staff 1660 2009-10-19 16:40:14 ./include/emittermanip.h
-rw-r - r-- beder / staff 171 2009-08-18 22: 07:22 ./include/._exceptions.h
-rw-r - r-- beder / staff 5638 2009-08-18 22:07:22 ./include/exceptions.h
- rw-r - r-- beder / staff 765 2009-07-29 15:25:23 ./include/iterator.h
-rw-r- -r-- beder / staff 444 2009-07-29 15:25:23 ./include/mark.h
-rw-r - r-- beder / staff 171 2009-09-06 12:25 :12 ./include/._node.h
-rw-r - r-- beder / staff 3467 2009-09-06 12:25:12 ./include/node.h
-rw -r - r - beder / staff 171 2009-09-15 20:54:20 ./include/._nodeimpl.h
...
-rw-r - r-- beder / staff 171 2009-07-29 21:28:26 ./include/._yaml.h
-rw-r - r-- beder / staff 321 2009-07-29 21:28:26 ./ include / yaml.h
-rw -r - r-- beder / staff 167 2009-09-05 16:01:06 ./._install.txt
-rw-r - r- - beder / staff 652 2009-09-05 16:01:06 ./install.txt
-rw-r - r-- beder / staff 1073 2009-05-29 19:31:21 ./license .txt
drwxr-xr-x beder / staff 0 2009-10-22 14:49:11 ./src/
-rw-r - r-- beder / staff 1697 2009-08- 24 16:28:46 ./src/aliascontent.cpp
-rw -r - r-- beder / staff 1171 2009-08-24 16:28:46 ./src/aliascontent.h
-rw-r -r- beder / staff 112 2009-05-29 19:31:21 ./src/content.cpp
-rw-r - r-- beder / staff 1557 2009- 08-24 16 :28:46 ./src/content.h
-rw-r - r-- beder / staff 171 2009-09-06 13:31:56 ./src/._conversion.cpp
-rw-r - r - beder / staff 2027 2009-09-06 13:31:56 ./src/conversion.cpp
...
所以这些不合法的文件随产品tar文件一起发货。你感染了某个地方 - 不知道如何。
The following issue popped up in my open source library, and I can't figure out what's going on.
Two of my users have (gcc) compiler errors that look like:
/home/someone/Source/src/._regex.cpp:1:1: warning: null character(s) ignored
/home/someone/Source/src/._regex.cpp:1: error: stray ‘\5’ in program
/home/someone/Source/src/._regex.cpp:1: error: stray ‘\26’ in program
/home/someone/Source/src/._regex.cpp:1: error: stray ‘\7’ in program
/home/someone/Source/src/._regex.cpp:1:5: warning: null character(s) ignored
/home/someone/Source/src/._regex.cpp:1: error: stray ‘\2’ in program
...
I can't reproduce these errors; the code compiles fine on all machines I've tested.
Googling around seemed to indicate that this is often a result of a strange encoding or strange formatting, but I ran all the source through a hex editor, and all characters are either printable ASCII (0x20 - 0x7E), or tab, or newline. That's it.
Also, both users successfully compiled the previous version of the library; but the particular file in question (regex.cpp
) and its header files haven't been modified since that time!
Please see here for more details, including links to download the code if you want. But I'd be happy with just a pointer in a possible direction.
解决方案
Baffe Boyois has got the right general answer - your CMake rules must be doing too much.
On MacOS X 10.5.8 (Leopard), I get:
Osiris JL: cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/jleffler/tmp/yaml-cpp-0.2.3/build
Osiris JL: make
Scanning dependencies of target yaml-cpp
[ 2%] Building CXX object CMakeFiles/yaml-cpp.dir/src/._conversion.cpp.o
/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1:1: warning: null character(s) ignored
/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1: error: stray ‘\5’ in program
/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1: error: stray ‘\22’ in program
/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1: error: stray ‘\7’ in program
/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1:5: warning: null character(s) ignored
/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1: error: stray ‘\2’ in program
/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1:7: warning: null character(s) ignored
/tmp/yaml-cpp-0.2.3/src/._conversion.cpp:1:17: warning: null character(s) ignored
...
You should list the files you need compiled; you should not just compile all and sundry.
The problem seems to be in CMakeLists.txt:
file(GLOB public_headers include/*.h)
file(GLOB private_headers src/*.h)
file(GLOB sources src/*.cpp)
Either the CMake GLOB is a bit too enthusiastic (I'm using version 2.6-patch 4) or you cannot afford to use it while any of your customers are using MacOS X.
What the GLOB is doing expanding to include files starting with '.' is anyone's guess; I'd be inclined to regard it as a bug in cmake.
However, as a workaround, I edited CMakeLists.txt and got this to work:
file(GLOB public_headers include/[a-z]*.h)
file(GLOB private_headers src/[a-z]*.h)
file(GLOB sources src/[a-z]*.cpp)
This isn't the complete solution: I ran into a continuation of the problem with the code in the yaml-reader directory. I modified the yaml-reader/CMakeLists.txt file in basically the same way.
FWIW:
$ file ._*
._conversion.cpp: AppleDouble encoded Macintosh file
._exp.cpp: AppleDouble encoded Macintosh file
._map.cpp: AppleDouble encoded Macintosh file
._map.h: AppleDouble encoded Macintosh file
._node.cpp: AppleDouble encoded Macintosh file
._null.cpp: AppleDouble encoded Macintosh file
._ostream.cpp: AppleDouble encoded Macintosh file
._parser.cpp: AppleDouble encoded Macintosh file
._regex.cpp: AppleDouble encoded Macintosh file
._regeximpl.h: AppleDouble encoded Macintosh file
._scanner.cpp: AppleDouble encoded Macintosh file
._scanner.h: AppleDouble encoded Macintosh file
._scanscalar.cpp: AppleDouble encoded Macintosh file
._scanscalar.h: AppleDouble encoded Macintosh file
._sequence.cpp: AppleDouble encoded Macintosh file
._simplekey.cpp: AppleDouble encoded Macintosh file
._stream.cpp: AppleDouble encoded Macintosh file
._token.h: AppleDouble encoded Macintosh file
$ odx ._con*.cpp
0x0000: 00 05 16 07 00 02 00 00 4D 61 63 20 4F 53 20 58 ........Mac OS X
0x0010: 20 20 20 20 20 20 20 20 00 02 00 00 00 09 00 00 ........
0x0020: 00 32 00 00 00 79 00 00 00 02 00 00 00 AB 00 00 .2...y..........
0x0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
*
0x0050: 00 00 00 00 41 54 54 52 00 3C E0 2B 00 00 00 AB ....ATTR.<.+....
0x0060: 00 00 00 9C 00 00 00 0F 00 00 00 00 00 00 00 00 ................
0x0070: 00 00 00 00 00 00 00 01 00 00 00 9C 00 00 00 0F ................
0x0080: 00 00 17 63 6F 6D 2E 61 70 70 6C 65 2E 54 65 78 ...com.apple.Tex
0x0090: 74 45 6E 63 6F 64 69 6E 67 00 00 00 55 54 46 2D tEncoding...UTF-
0x00A0: 38 3B 31 33 34 32 31 37 39 38 34 8;134217984
0x00AB:
$
One odd detail - some of the files in the 'src' directory do not have the shadow files. When I do 'tar -tvf yaml-cpp-0.2.3.tar.gz', I see the files being shipped with the source:
Osiris JL: tar -tvf yaml-cpp-0.2.3.tar.gz
drwxr-xr-x beder/staff 0 2009-10-22 15:13:52 ./
-rw-r--r-- beder/staff 1750 2009-10-22 15:09:05 ./CMakeLists.txt
drwxr-xr-x beder/staff 0 2009-10-19 16:40:15 ./include/
-rw-r--r-- beder/staff 171 2009-09-06 13:41:54 ./include/._conversion.h
-rw-r--r-- beder/staff 1118 2009-09-06 13:41:54 ./include/conversion.h
-rw-r--r-- beder/staff 302 2009-07-29 15:25:23 ./include/crt.h
-rw-r--r-- beder/staff 2254 2009-10-19 16:40:14 ./include/emitter.h
-rw-r--r-- beder/staff 1660 2009-10-19 16:40:14 ./include/emittermanip.h
-rw-r--r-- beder/staff 171 2009-08-18 22:07:22 ./include/._exceptions.h
-rw-r--r-- beder/staff 5638 2009-08-18 22:07:22 ./include/exceptions.h
-rw-r--r-- beder/staff 765 2009-07-29 15:25:23 ./include/iterator.h
-rw-r--r-- beder/staff 444 2009-07-29 15:25:23 ./include/mark.h
-rw-r--r-- beder/staff 171 2009-09-06 12:25:12 ./include/._node.h
-rw-r--r-- beder/staff 3467 2009-09-06 12:25:12 ./include/node.h
-rw-r--r-- beder/staff 171 2009-09-15 20:54:20 ./include/._nodeimpl.h
...
-rw-r--r-- beder/staff 171 2009-07-29 21:28:26 ./include/._yaml.h
-rw-r--r-- beder/staff 321 2009-07-29 21:28:26 ./include/yaml.h
-rw-r--r-- beder/staff 167 2009-09-05 16:01:06 ./._install.txt
-rw-r--r-- beder/staff 652 2009-09-05 16:01:06 ./install.txt
-rw-r--r-- beder/staff 1073 2009-05-29 19:31:21 ./license.txt
drwxr-xr-x beder/staff 0 2009-10-22 14:49:11 ./src/
-rw-r--r-- beder/staff 1697 2009-08-24 16:28:46 ./src/aliascontent.cpp
-rw-r--r-- beder/staff 1171 2009-08-24 16:28:46 ./src/aliascontent.h
-rw-r--r-- beder/staff 112 2009-05-29 19:31:21 ./src/content.cpp
-rw-r--r-- beder/staff 1557 2009-08-24 16:28:46 ./src/content.h
-rw-r--r-- beder/staff 171 2009-09-06 13:31:56 ./src/._conversion.cpp
-rw-r--r-- beder/staff 2027 2009-09-06 13:31:56 ./src/conversion.cpp
...
So the miscreant files are being shipped with the product tar file. You got infected somewhere - not sure how.
这篇关于奇怪的海湾合作委员会错误:在程序中散布'\NNN'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!