Make your own interface by writing a little bit of code.
void OutputDebug(const char* s)
{
OutputDebugStringA(s);
}
void OutputDebug(const std::string& s)
{
OutputDebug(s.c_str());
}
void OutputDebug(const std::stringstream& s)
{
OutputDebug(s.str());
}
if ( hFileConnection == INVALID_HANDLE_VALUE ) {
std::stringstream s;
s << __func__ << " had GetLastError = " << GetLastError() << endl;
OutputDebug(s);
OutputDebug("\n");
}
If you want to get fancy, you can add a little type and overload operator<<
.
Even something simple and incomplete like this could prove useful and is sometimes all the fanciness you need:
// Empty types are surprisingly useful.
// This one is only a "hook" that we can attach 'operator<<' to
// in order to use stream insertion syntax.
struct DebugOutput {};
template<typename T>
DebugOutput& operator<<(DebugOutput& lhs, const T& rhs)
{
std::stringstream ss;
ss << rhs;
OutputDebugStringA(ss.str().c_str());
return lhs;
}
int main()
{
DebugOutput debug;
debug << "hello" << 23 << "\n";
}