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