C编译:错误:在程序中丢失'\ 4';八进制流? [英] C Compiling: error: stray '\4' in program ; octal flow?

查看:235
本文介绍了C编译:错误:在程序中丢失'\ 4';八进制流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(1)使用 cc 编译好的文件,

  cc -Wall -Wextra -Wunreachable-code -ggdb -O0 * .c 
  ar cru liborientdb-ca * .o 



<3>工作正常。但是,当我编译包含第1行中的库的c ++程序testme.cpp时,请仔细阅读以下内容:

 (testme的第1行。 cpp)
#includeliborientdb-ca

编译步骤:

  cc testme.cpp 

我得到这个错误:

  liborientdb-ca:117:22:error:stray'\3'in program 
liborientdb-ca:117:263:警告:null字符被忽略[默认情况下启用]
liborientdb-ca:117:22:错误:程序中的'\17'错误
liborientdb-ca:117:265:警告:忽略空字符[默认情况下启用]
liborientdb-ca:117:283:警告:空字符被忽略[默认情况下启用]
liborientdb-ca:117:22:错误:在程序
中丢失'\22'liborientdb-ca:117:287:警告:空字符被忽略[默认情况下启用]
liborientdb-ca :程序
liborientdb-ca:117:289:警告:空ch:117:22:error:stray'\1'字符(s)被忽略[默认情况下启用]
liborientdb-ca:117:22:错误:在程序
....中丢失'\362'

因此,遵循其他人的建议这里,我相信这些错误可能是由于编码混乱。

因此,我使用'od -c'并尝试追踪八进制流变得混乱的地方。我的一个.o文件在'od -c'之后的输出看起来很糟糕,所以我认为这可能是原因。



EG。

  0000000 177 ELF 002 001 001 \0\\\\\\\\\\\\\\\\\\\\\ \0 
0000020 001 \0> \0 001 \0 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 0 \0 \0\\\\\\\\\\\\\\\\\\'\\\\\\\\' \0 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ?
0000120 H 213 E?H 213 \ 0 H 213 @ \ H 205?t 023
0000140 H 213 E?H 213 \ 0 H 213 @ \ H 211?? \0

我该如何解决这个问题?我实际上是遵循了这里并运行在我的lib源文件上

  recode UTF8..ISO-8859-15 * .c 

答案是f iles保持不变(最后修改的日期仍然是旧的)然后我打开我的.c文件,看到它们是UTF-8,这显然是ASCII的一个子集,所以这看起来没有问题。



但是.o文件看起来很奇怪。



如何继续??? <解决方案


.a文件不是C源文件。或者甚至是文本文件。



通常,.a文件被添加到编译的最后一个链接行。



cc -o something file.o file2.o liborientdb-ca etc等等


Trying to compile a load of .c files

(1) The files compile ok, using cc

cc -Wall -Wextra -Wunreachable-code -ggdb -O0 *.c 

(2) Then, I need to make a static library from the final output, to use in a c++ program. So I do:

ar cru liborientdb-c.a *.o

(3) Works ok. However when I come to compile the c++ program testme.cpp that includes the library in line #1

(line 1 of testme.cpp)
#include "liborientdb-c.a"

Compile step:

cc testme.cpp

i get this error:

liborientdb-c.a:117:22: error: stray '\3' in program
liborientdb-c.a:117:263: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:22: error: stray '\17' in program
liborientdb-c.a:117:265: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:283: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:22: error: stray '\22' in program
liborientdb-c.a:117:287: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:22: error: stray '\1' in program
liborientdb-c.a:117:289: warning: null character(s) ignored [enabled by default]
liborientdb-c.a:117:22: error: stray '\362' in program
....

So, following the advice on some others posts here, i believe the errors could be due to messed up encoding.

So i used 'od -c' and to try and trace where the "octal flow" is getting messed up. The output for one of my .o files after with 'od -c' looks pretty bad, so i think that could be the reason.

EG.

0000000 177   E   L   F 002 001 001  \0  \0  \0  \0  \0  \0  \0  \0  \0
0000020 001  \0   >  \0 001  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
0000040  \0  \0  \0  \0  \0  \0  \0  \0   `   (  \0  \0  \0  \0  \0  \0
0000060  \0  \0  \0  \0   @  \0  \0  \0  \0  \0   @  \0 026  \0 023  \0
0000100   U   H 211   ?   H 203   ? 020   H 211   }   ?   H 211   u   ?
0000120   H 213   E   ?   H 213  \0   H 213   @  \b   H 205   ?   t 023
0000140   H 213   E   ?   H 213  \0   H 213   @  \b   H 211   ?   ?  \0

How can i fix this though? I actually followed the advice here and ran on my lib source files

recode UTF8..ISO-8859-15 *.c

The response is the files remain unchanged (the last modified date is still old). So then I open my .c files and see they are in UTF-8, which is apparently a subset of ASCII. So it would seem no issue then.

But the .o files still look weird.

How to proceed ???

解决方案

#include "liborientdb-c.a"

.a files are not C source files. Or even text files for that matter.

Usually, the .a files are added on the final link line of the compilation.

cc -o something file.o file2.o liborientdb-c.a etc etc

这篇关于C编译:错误:在程序中丢失'\ 4';八进制流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆