Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem using OutputDebugString

892 views
Skip to first unread message

Richard Muller

unread,
Jan 4, 2003, 5:21:07 PM1/4/03
to
Hi,

I generated a "Hello, World" console app. using Win2000ProSP3 and
VisualStudioSP5. I added two statements: an OutputDebugString statement and
an "include" statement for Winbase.h, as follows:

#include <Winbase.h>
#include "stdafx.h"

int main(int argc, char* argv[])
{
OutputDebugString("Hello World!\n");
printf("Hello World!\n");
return 0;
}

The compiler complains:

error C2065: 'OutputDebugString' : undeclared identifier

However, 'OutputDebugString' *is* defined in Winbase.h, lines 4438, etc., as
follows:

#ifdef UNICODE
#define OutputDebugString OutputDebugStringW
#else
#define OutputDebugString OutputDebugStringA
#endif // !UNICODE

I'd expect a link error, but I don't understand why there's a compile error.
Thanks in advance for any suggestions.

Richard


Richard Muller

unread,
Jan 4, 2003, 7:01:13 PM1/4/03
to
I added "#pragma message ("XXX)" statements to both stdafx.h (in the project
dir) and winbase.h (in the ....Visual Studio\VC98\Include dir.)

The stdafx pragma fired, but the winbase pragma did not, yet the compiler
didn't complain that it couldn't find the winbase header.

Though I thougt it pointless, I added the above include dir. to
Project|Settings| Settings for All Configs|C++ tab|Preprocessor
category|Additional include directories. That made no difference.


Richard Muller

unread,
Jan 4, 2003, 11:40:11 PM1/4/03
to
I added the code below, which I copied from WinBase.h to stdafx.h.
However, I'd like a better way to do this.
If I simply include WinBase.h (without the Windows.h include), I get
compilation errors.
If I include WinBase.h after the Windows.h include, _WINBASE_ is defined
and hence WinBase.h does not get expanded.

Any suggestions would be greatly appreciated.

#include <windows.h>

WINBASEAPI
VOID
WINAPI
OutputDebugStringA(
LPCSTR lpOutputString
);
WINBASEAPI
VOID
WINAPI
OutputDebugStringW(
LPCWSTR lpOutputString
);

Joseph Steel

unread,
Feb 16, 2003, 3:39:59 PM2/16/03
to
Have you tried just:
#include <windows.h>
I've always found it difficult to include specific
windows headers.
You can always use:
#define WIN32_LEAN_AND_MEAN

>.
>

Richard Muller

unread,
Feb 22, 2003, 4:33:01 AM2/22/03
to
Hi,

Thanks for your response. That got me to look at my problem anew and, sure
enough, windows.h in a brand new Win32 App supports OutputDebugString. I
don't know why I thought I needed the kludge I concocted last month.

Regards,
Richard

"Joseph Steel" <j.s...@rmcs.cranfield.ac.uk> wrote in message
news:02c801c2d5fb$92a37a50$3001...@phx.gbl...

0 new messages