经历1:

         某次, 在某大型工程中, 我多敲了一个空格, 于是, 在编译的时候一直报错。 下面给出一个例子:

 

[taoge@localhost Desktop]$ cat main.c 
#include < stdio.h>

int main()
{
	return 0;
}
[taoge@localhost Desktop]$ gcc main.c 
main.c:1:20: error:  stdio.h: No such file or directory
[taoge@localhost Desktop]$

 

         编译的时候, 找不到头文件, 但我看到头文件明明在对应的目录下啊, 经过一段时间的仔细确认, 终于发下了程序的错误, 原来多了一个空格, 如上。

 

 

         经历2:

         某次, 两个终端登录同一服务器的同一目录, 执行相同的操作, 结果得到不同的结果。

         经过一段时间的跟踪确认, 终于发现, 这么目录下有两个几乎完全一致的文件, 如下:

 

[taoge@localhost test]$ ls
[taoge@localhost test]$ touch "a.txt" " a.txt"
[taoge@localhost test]$ ls
 a.txt  a.txt
[taoge@localhost test]$ ll
total 0
-rw-rw-r-- 1 taoge taoge 0 Oct 27 08:45  a.txt
-rw-rw-r-- 1 taoge taoge 0 Oct 27 08:45 a.txt
[taoge@localhost test]$ 

 

 

 

 

 

        经历3: 

        不是我的经历, 某程序员写下了如下代码并编译, 如下:

 

[taoge@localhost test]$ cat test.cpp 
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main()
{
	vector<map<int, int>> v;
	return 0;
}
[taoge@localhost test]$ g++ test.cpp 
test.cpp: In function ‘int main()’:
test.cpp:8: error: ‘>>’ should be ‘> >’ within a nested template argument list
[taoge@localhost test]$ 

       该怎么修改, 我就不说了, 上面的提示已经说得很清楚了。 当然, 在C++ 11中, 上述程序是OK的, 但不要依赖于这种靠兼容吃饭的行为。

 

 

  

       空格虽小, 不可忽视。 睡觉。

 

 

 

 


 

 


本文转载:CSDN博客