看程序:

#include <iostream>
using namespace std;

int main()
{
	char szTest[] = "abcxxx";
	printf("defxxx\n");
	return 0;
}
     看g++和stings:

taoge@localhost Desktop> g++ test.cpp &&  strings a.out | grep abc
abcxxx
taoge@localhost Desktop> g++ test.cpp &&  strings a.out | grep def
defxxx
taoge@localhost Desktop> g++ test.cpp -O2 &&  strings a.out | grep abc
taoge@localhost Desktop> g++ test.cpp -O2 &&  strings a.out | grep def
defxxx
taoge@localhost Desktop> 
    

     所以, 如果我们要对程序加入“印记”, 最好是用log形式(如printf), 而不是用char szTest[]方式。 总之, 是为了方便用strings准确鉴别出改动。





本文转载:CSDN博客