How to write to the debugging stream?

Asked by Lucian Bazoi

Hi,

  I tried to write to a debug stream but I get the following error:

adapter_passthru.cc:219: error: invalid operands of types "std::ostream*" and const char [26] to binary "operator<<"
adapter_passthru.cc: At global scope:

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

What is missing?
Thank you

Question information

Language:
English Edit question
Status:
Answered
For:
eCAP Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
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.

Revision history for this message
Okhterov Egor (longhorn4500) said :
#2

I get different error:
adapter_minimal.cc:168:49: 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,
                 from adapter_minimal.cc:4:
/usr/local/include/libecap/common/forward.h:32:8: error: forward declaration of ‘class libecap::host::Host’
  class Host;
        ^
adapter_minimal.cc:169:17: error: expected constructor, destructor, or type conversion before ‘<<’ token
 (*debug_stream) << "Global debug message from simple adapter";
                 ^
adapter_minimal.cc:170:20: error: expected constructor, destructor, or type conversion before ‘.’ token
 (libecap::MyHost()).closeDebug(debug_stream);
                    ^
adapter_minimal.cc:166:19: 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

Revision history for this message
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.