Message-ID: <002f01c078f2$74cd3c40$ed06893e@oemcomputer> From: "Stephen Silver" To: Subject: namespace std - examples Date: Sun, 7 Jan 2001 21:40:28 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Reply-To: djgpp-workers AT delorie DOT com Here are some examples to demonstrate the problems DJGPP currently has with namespace std. Consider these four Hello World programs: // #1 #include int main() { puts("Hello, World!"); } // #2 #include int main() { std::puts("Hello, World!"); } // #3 (invalid) #include int main() { puts("Hello, World!"); } // #4 #include 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 #include 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