C++ compiler problems with FC2

Paul paul at all-the-johnsons.co.uk
Tue Aug 31 20:18:49 UTC 2004


Hi,

> I must be a bit thick today.  I don't understand why:
> 
> - it compiled cleanly under g++ 3.3.1 on FC1, but not 3.3.3 on FC2

From rom what you've shown here, it shouldn't have.

> - cstring depends on cstdlib being included first and doesn't include it 
> itself

It doesn't

#include <cstring>
#include <iostream>

using namespace std;

int main()
{
  char x[20];
  strncpy(x, "Helllllo from Fedora Core!", 19);
  cout << x << "\n";
}

g++ scr.cpp -o scr
./scr
Helllllo from Fedor

As another quicky, I removed the iostream and cout lines and it was
still happy.

> - how including cstring will resolve problems with cstring.

cstring contains all of the C string header encapsulated in the standard
namespace. These include strcpy, strlen etc

> - how setting the namespace after the includes will have any effect on 
> errors that arise from including header files.

Because without it, you're not defining the namespace which you're
using. Everything in C++ is defined within the std namespace (unless
otherwise stated - such as other libraries which are not part of the
standard)

> - how this code failed when your test code worked.  I just rearranged 
> main.cpp so the first lines read:

> #include <cstdlib>
> #include <cstring>
> #include <iostream>
> 
> ... rest of the program as before
> 
> 
> and the same errors result.  I guess that it is time to dig into the g++ 
> options this code is using.

Email me off list with the source and I'll have a look. As I've said,
gcc under FC2 caused me no problems at all - 3000+ source files later
and everything happy.

TTFN

Paul
-- 
"Our enemies are innovative and resourceful - and so are we,"
"They never stop thinking about new ways to harm our country and our
people - and neither do we." - George W. Bush, Aug 2004
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.fedoraproject.org/pipermail/test/attachments/20040831/eb641d53/attachment.bin 


More information about the test mailing list