[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PATCH: use C++ io in tagdemo tests
From: |
Robert Boehne |
Subject: |
PATCH: use C++ io in tagdemo tests |
Date: |
Mon, 01 Apr 2002 12:48:07 -0600 |
(I remembered the patch this time... :)
Although it may seem trivial, it really isn't. On many
platforms the tagdemo test will pass, even when straight-up
'ld' is used to link. That is because the tagdemo doesn't
happen to reference anything (in such a case) in the C++ runtime.
This trivial patch changes <stdio.h> printf to <iostream.h> cout <<.
I picked iostream.h rather than iostream because it is more
common with older compilers, and new ones generally support
it as well. If I find that someone has a compiler with
only <iostream> and no <iostream.h> then I can add a configure
test for both. The problem with doing that now is that
it cascades into testing for namespace usage, std:: namespace
usage in IO classes... etc.
ChangeLog entry:
2002-03-14 Robert Boehne <address@hidden>
tagdemo/foo.cpp: Use C++ IO to catch problems linking to C++ runtime
libraries.
tagdemo/main.cpp: Ditto.
Ok to commit?
Robert
--
Robert Boehne Software Engineer
Ricardo Software Chicago Technical Center
TEL: (630)789-0003 x. 238
FAX: (630)789-0127
email: address@hidden
Index: tagdemo/foo.cpp
===================================================================
RCS file: /cvsroot/libtool/libtool/tagdemo/foo.cpp,v
retrieving revision 1.3
diff -u -r1.3 foo.cpp
--- tagdemo/foo.cpp 6 Jun 2001 14:53:29 -0000 1.3
+++ tagdemo/foo.cpp 1 Apr 2002 18:29:46 -0000
@@ -20,7 +20,7 @@
// USA.
#include "foo.h"
-#include <stdio.h>
+#include <iostream.h>
#ifdef HAVE_MATH_H
#include <math.h>
@@ -30,14 +30,14 @@
int
foo(void)
{
- printf ("cos (0.0) = %g\n", (double) cos ((double) 0.0));
+ cout << "cos (0.0) = " << (double) cos ((double) 0.0) << endl;
return FOO_RET;
}
int
hello(void)
{
- printf ("** This is libfoo (tagdemo) **\n");
+ cout << "** This is libfoo (tagdemo) **" << endl;
return HELLO_RET;
}
Index: tagdemo/main.cpp
===================================================================
RCS file: /cvsroot/libtool/libtool/tagdemo/main.cpp,v
retrieving revision 1.3
diff -u -r1.3 main.cpp
--- tagdemo/main.cpp 6 Jun 2001 14:53:29 -0000 1.3
+++ tagdemo/main.cpp 1 Apr 2002 18:29:46 -0000
@@ -22,13 +22,13 @@
#include "foo.h"
#include "baz.h"
-#include <stdio.h>
+#include <iostream.h>
int
main (int, char *[])
{
- printf ("Welcome to GNU libtool tagdemo!\n");
+ cout << "Welcome to GNU libtool tagdemo C++!" << endl;
foobar_derived FB;
// Instantiate the derived class.
@@ -38,12 +38,12 @@
int value = fb->hello();
- printf ("foobar::hello returned: %i\n", value);
+ cout << "foobar::hello returned: " << value << endl;
if (value == HELLO_RET)
- printf("foobar::hello is ok!\n");
+ cout << "foobar::hello is ok!" << endl;
if (fb->foo() == FOO_RET)
- printf("foobar::foo is ok!\n");
+ cout << "foobar::foo is ok!" << endl;
// --------------
@@ -57,7 +57,7 @@
// barbaz_derived::baz() should return FOO_RET since it calls
// foobar_derived::foo(), which in turn calls ::foo().
if (bb->baz() == FOO_RET)
- printf("barbaz::baz is ok!\n");
+ cout << "barbaz::baz is ok!" << endl;
return 0;
}