This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc4.1.2 and 4.3.2 has different default behavior
- From: Ian Lance Taylor <iant at google dot com>
- To: Yixuan Huang <yixuan178 at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 08 Mar 2011 23:08:10 -0800
- Subject: Re: gcc4.1.2 and 4.3.2 has different default behavior
- References: <AANLkTimri--F2kMqo8X30o3-CPRRG4mu5ZYkM=Ub1yG0@mail.gmail.com>
Yixuan Huang <yixuan178@gmail.com> writes:
> I have encountered one issue when write a simple test code.
> #inlcude <iostream>
> int main{
> const char* str = "aaaa";
> std::cout<<"str len: "<<strlen(str)<<std::endl;
> return 0;
> }
>
> If I compile on gcc version 4.1.2 20070115 (SUSE Linux), it can be
> compiled successfully. Otherwise, on gcc version 4.3.2 [gcc-4_3-branch
> revision 141291] (SUSE Linux), it will show
> linux-lht2:/home/yixuan # g++ aa.cpp
> aa.cpp: In function âint main()â:
> aa.cpp:6: error: âstrlenâ was not declared in this scope
>
> I don't know where can I get the information to explain the different behavior?
This message is not appropriate for the mailing list gcc@gcc.gnu.org.
It would be appropriate for gcc-help@gcc.gnu.org. Please take any
followups to gcc-help. Thanks.
gcc 4.3 is more careful about having one C++ header file include
another. The function strlen is defined in <string.h>. In gcc 4.1
<iostream> #include'd <string.h>. In gcc 4.3 it does not.
This is briefly mentioned at http://gcc.gnu.org/gcc-4.3/changes.html:
"Header dependencies have been streamlined, reducing unnecessary
includes and pre-processed bloat."
Ian