How to write to the debugging stream?

Asked by Lucian Bazoi on 2010-12-15


  I tried to write to a debug stream but I get the following error: error: invalid operands of types "std::ostream*" and const char [26] to binary "operator<<" At global scope:

        std::ostream *ostr = (libecap::MyHost()).openDebug(6);
        ostr<<"Some random text";

What is missing?
Thank you

Question information

English Edit question
eCAP Edit question
No assignee Edit question
Last query:
Last reply:
Alex Rousskov (rousskov) said : #1

You are writing into a stream pointer (ostr) instead of writing into a stream (*ostr). Try this instead:

    (*ostr) << "Some random text";

BTW, I do not think you need to surround libecap::MyHost() with parens.

Okhterov Egor (longhorn4500) said : #2

I get different error: error: invalid use of incomplete type ‘class libecap::host::Host’
 std::ostream* debug_stream = (libecap::MyHost()).openDebug(6);
In file included from /usr/local/include/libecap/common/registry.h:6:0,
/usr/local/include/libecap/common/forward.h:32:8: error: forward declaration of ‘class libecap::host::Host’
  class Host;
        ^ error: expected constructor, destructor, or type conversion before ‘<<’ token
 (*debug_stream) << "Global debug message from simple adapter";
                 ^ error: expected constructor, destructor, or type conversion before ‘.’ token
                    ^ warning: ‘Registered’ defined but not used [-Wunused-variable]
 static const bool Registered = (libecap::RegisterService(new Adapter::Service), true);
make[2]: *** [adapter_minimal.lo] Error 1

Alex Rousskov (rousskov) said : #3

The "incomplete type ‘class libecap::host::Host’" error means you forgot to #include "libecap/host/host.h".

The "expected constructor, destructor, or type conversion" errors are a side-effect of the above error.

The "defined but not used" warning may go away after you fix other errors. If it does not, you may ignore the warning OR find a compiler-specific way to quiet it.

Can you help with this problem?

Provide an answer of your own, or ask Lucian Bazoi for more information if necessary.

To post a message you must log in.