Mail Archives: djgpp-workers/2001/01/07/16:40:36
Here are some examples to demonstrate the problems DJGPP currently
has with namespace std.
Consider these four Hello World programs:
// #1
#include <stdio.h>
int main()
{
puts("Hello, World!");
}
// #2
#include <stdio.h>
int main()
{
std::puts("Hello, World!");
}
// #3 (invalid)
#include <cstdio>
int main()
{
puts("Hello, World!");
}
// #4
#include <cstdio>
int main()
{
std::puts("Hello, World!");
}
At present, all of these (including the invalid one) compile with gpp.
However, this is a little meaningless, because gpp currently uses the
non-ANSI-compliant -fno-honor-std switch by default. If -fhonor-std
is used (as will presumably be the default in future versions of GCC),
then only #1 and #3 compile.
As a further example, the following valid (but severely contrived) C++
program currently doesn't compile at all, whether or not -fhonor-std
is used:
#include <cmath>
#include <stdio.h>
const char *sin = "avarice";
int main()
{
printf("%s\n", sin);
}
By contrast with DJGPP, Borland C++ 5.5.1 deals with all the above
examples correctly, i.e., the invalid #3 doesn't compile, but all
the rest compile and run as expected.
Stephen
- Raw text -