Git打破了我的程序? [英] Git breaks my program?

查看:606
本文介绍了Git打破了我的程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个程序,我在一个主分支下编写,我使用GNUmakefile编译。今天,在我创建了一个新的分支,v4.3,并切换到新的分支,然后编译之后,我得到以下错误消息:

  lucerne:lucerne $ make primes 
g ++ - mp-4.8 -std = gnu ++ 0x -g -O2 -W -Wall -Wextra -MD -MF .deps / primes.d -MP -一世。 -c -o primes.o primes.cpp
在从primes.cpp:2:0包含的文件中:
./vector:1:1:error:stray'\317'in program
???? _ TEXT
^
./vector:1:1:error:stray'\372'in program
./vector:1:1:error:stray' \355'in program
./vector:1:1:error:stray'\376'in program
./vector:1:1:error:stray'\7'in program
./vector:1:6:warning:null字符被忽略[默认启用]
./vector:1:1:错误:程序中的stray'\1'
./vector:1:1:error:stray'\3'in program
./vector:1:10:warning:null字符被忽略[默认启用]
./ vector:1:1:error:stray'\200'in program

消息,当我切换到主分支。但是,如果我将文件重命名为其他名称,如new_primes.cpp,则 make file 不会导致任何问题。 GNUmakefile或prime.cpp都没有被修改。我也没有安装任何额外的包。它也不是编辑 - 我使用emacs和TextWrangler。是什么原因导致这个问题?

解决方案

当源文件(在这种情况下,包含文件)是二进制文件时,会生成GCC错误。这很容易通过创建具有单个包含到二进制文件/ bin / ls的源文件来重现。创建stray.c与:

  #include/ bin / ls
/ pre>

快速完成:

  gcc -c stray。 c 

产生以下输出:

 在stray.c:1:0包含的文件中:
/ bin / ls:1:1:error:stray'\177'in program
/ bin / ls:1:1:错误:程序中的stray'\2'
/ bin / ls:1:1:错误:程序中的stray'\1'
/ bin / ls:1 :1:错误:程序中的stray'\1'
/ bin / ls:1:8:警告:忽略空字符[默认启用]
/ bin / ls: 1:错误:程序中的stray'\2'
/ bin / ls:1:18:warning:null字符被忽略[默认启用]
/ pre>

看来'vector'是一个二进制文件。



有两种可能的原因


  1. C ++'vector'头文件已损坏。

  2. 矢量。

我猜它的第二个。检查并确保在编译器包含路径中没有二进制称为向量。


I have several programs that I have been writing under a master branch, which I compile using GNUmakefile. Today, right after I created a new branch, v4.3, and switched onto the new branch, and then compile, I get the following error message:

lucerne:lucerne$ make primes
g++-mp-4.8 -std=gnu++0x -g -O2 -W -Wall -Wextra  -MD -MF .deps/primes.d -MP  -I. -c -o primes.o primes.cpp
In file included from primes.cpp:2:0:
./vector:1:1: error: stray '\317' in program
 ????_TEXT
 ^
./vector:1:1: error: stray '\372' in program
./vector:1:1: error: stray '\355' in program
./vector:1:1: error: stray '\376' in program
./vector:1:1: error: stray '\7' in program
./vector:1:6: warning: null character(s) ignored [enabled by default]
./vector:1:1: error: stray '\1' in program
./vector:1:1: error: stray '\3' in program
./vector:1:10: warning: null character(s) ignored [enabled by default]
./vector:1:1: error: stray '\200' in program

I get the same error message when I switch to master branch. However, if I rename the file to something else, like "new_primes.cpp", then make file does not cause any problem. Neither GNUmakefile or prime.cpp has been modified. I also have not installed any additional packages. It is also not the editor - I am using emacs and TextWrangler. What is causing this problem?

解决方案

The error generated by GCC occurs when the source file, or in this case, included file is a binary file. This is easily reproduced by creating a source file with a single include to a binary file, /bin/ls for example. Create stray.c with:

#include "/bin/ls"

A quick complie:

gcc -c stray.c

Yields the following output:

In file included from stray.c:1:0:
/bin/ls:1:1: error: stray '\177' in program
/bin/ls:1:1: error: stray '\2' in program
/bin/ls:1:1: error: stray '\1' in program
/bin/ls:1:1: error: stray '\1' in program
/bin/ls:1:8: warning: null character(s) ignored [enabled by default]
/bin/ls:1:1: error: stray '\2' in program
/bin/ls:1:18: warning: null character(s) ignored [enabled by default]

It appears that 'vector' is a binary file.

There are two possible causes that come to mind:

  1. The C++ 'vector' header file is corrupt.
  2. There is another 'vector' in your search path.

I'm guessing its the second. Check and make sure you don't have a binary called vector within the compiler include path.

这篇关于Git打破了我的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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