In message <[EMAIL PROTECTED]>, Ossama Othman writes:
>Something like the following should be a good smoke test:
>
>  class Foo
>  {
>   public:
>     Foo (void) : bar_ (0) { }
>     virtual ~Foo (void) { }
>     virtual int bar (void) { return this->bar_; }
>   private:
>     int bar_;
>  };
>
>  int main (int, char *[])
>  {
>   Foo fnord;
>   int a = fnord.bar ();
>   return a;
>  }

Just noticed a problem with this.  If you compile it with:

gcc -o test test.cc

You get a working executable called test.  But in gcc won't link this
C++ program:

#include <iostream>
int main() { cout << "hello world\n"; return 0; }

This is what happens (gcc 2.95.2 on Linux):

$ gcc -o a.out test2.cc
/tmp/ccx2KlXv.o: In function main':
/tmp/ccx2KlXv.o(.text+0xf): undefined reference to cout'
/tmp/ccx2KlXv.o(.text+0x14): undefined reference to ostream::operator<<(char const *)'
collect2: ld returned 1 exit status

Both programs compile and run fine when using g++ in place of gcc.

So it looks like the test program probably ought to use at least one
library function to make sure that the right libraries are getting
linked in.

Thoughts as to a good candidate?

Cheers,
Olly

Reply via email to