All,

I could use some direction here. I am learning C++, although I have
programmed in C for some time.

I am also working with ATL objects and have been doing quite well.

My problem is that I am getting "Undeclared Identifiers" on function names
and structures for NetWkstaUserGetInfo, NetApiBufferFree, and others
although I have <windows.h> and <lm.h> included. I looked at <lm.h> and it
includes <lmwksta.h> which has the actual definitions in it.

I have used the API call GetUserName with success.

My question is what in the blazes am I doing wrong?

TIA,

Justin

Re: undeclared identifier by William

William
Thu Nov 20 17:37:22 CST 2003

"Justin" <Unk@unknown.com> wrote in message
news:#fCtxd6rDHA.640@tk2msftngp13.phx.gbl...
> My problem is that I am getting "Undeclared Identifiers" on function names
> and structures for NetWkstaUserGetInfo, NetApiBufferFree, and others
> although I have <windows.h> and <lm.h> included. I looked at <lm.h> and it
> includes <lmwksta.h> which has the actual definitions in it.

Chances are that the compiler doesn't realize that you target Windows
NT/2000/XP/2K+3

Try adding this line

#define _WIN32_WINNT 0x0400

ahead of the place in your source where you included <windows.h> or a header
that includes it.

Regards,
Will




Re: undeclared identifier by Justin

Justin
Fri Nov 21 08:09:08 CST 2003

William,

Thanks for the response. I tried your suggestion. Still received the same
errors.

I created a blank console program and tried the code and it compiled with
success. I created a new ATL project and tried the same code and it gives
the compile errors of undeclared Identifier.

I don't know if it something to do with the ATL configuration or what.

The strange part is that if you hold the cursor above the definition, it
lists the typedef. So, I know it is finding the header file and definition.

I do appreciate the time.

Justin


"William DePalo [MVP VC++]" <willd@mvps.org> wrote in message
news:#QggC97rDHA.4056@TK2MSFTNGP11.phx.gbl...
> "Justin" <Unk@unknown.com> wrote in message
> news:#fCtxd6rDHA.640@tk2msftngp13.phx.gbl...
> > My problem is that I am getting "Undeclared Identifiers" on function
names
> > and structures for NetWkstaUserGetInfo, NetApiBufferFree, and others
> > although I have <windows.h> and <lm.h> included. I looked at <lm.h> and
it
> > includes <lmwksta.h> which has the actual definitions in it.
>
> Chances are that the compiler doesn't realize that you target Windows
> NT/2000/XP/2K+3
>
> Try adding this line
>
> #define _WIN32_WINNT 0x0400
>
> ahead of the place in your source where you included <windows.h> or a
header
> that includes it.
>
> Regards,
> Will
>
>
>



Re: undeclared identifier by Justin

Justin
Fri Nov 21 11:36:41 CST 2003

The solution was found.

It appears that with pre-compiled headers, header includes must come after
StdAfx.h.

Thanks all,

Justin

"Justin" <Unk@unknown.com> wrote in message
news:#vMzikDsDHA.4092@tk2msftngp13.phx.gbl...
> William,
>
> Thanks for the response. I tried your suggestion. Still received the same
> errors.
>
> I created a blank console program and tried the code and it compiled with
> success. I created a new ATL project and tried the same code and it gives
> the compile errors of undeclared Identifier.
>
> I don't know if it something to do with the ATL configuration or what.
>
> The strange part is that if you hold the cursor above the definition, it
> lists the typedef. So, I know it is finding the header file and
definition.
>
> I do appreciate the time.
>
> Justin
>
>
> "William DePalo [MVP VC++]" <willd@mvps.org> wrote in message
> news:#QggC97rDHA.4056@TK2MSFTNGP11.phx.gbl...
> > "Justin" <Unk@unknown.com> wrote in message
> > news:#fCtxd6rDHA.640@tk2msftngp13.phx.gbl...
> > > My problem is that I am getting "Undeclared Identifiers" on function
> names
> > > and structures for NetWkstaUserGetInfo, NetApiBufferFree, and others
> > > although I have <windows.h> and <lm.h> included. I looked at <lm.h>
and
> it
> > > includes <lmwksta.h> which has the actual definitions in it.
> >
> > Chances are that the compiler doesn't realize that you target Windows
> > NT/2000/XP/2K+3
> >
> > Try adding this line
> >
> > #define _WIN32_WINNT 0x0400
> >
> > ahead of the place in your source where you included <windows.h> or a
> header
> > that includes it.
> >
> > Regards,
> > Will
> >
> >
> >
>
>



Re: undeclared identifier by harry_bosch

harry_bosch
Fri Nov 21 22:53:41 CST 2003

"Justin" <Unk@unknown.com> wrote:

> The solution was found.
>
> It appears that with pre-compiled headers, header includes must come
> after StdAfx.h.

This is a kind of oddity with the MS compiler. If you're using precompiled
headers, the compiler will simply ignore anything above the #include
"stdafx.h" line (or whatever filename you're using).

You could write, literally:

THIS IS GARBAGE....
#include "stdafx.h"

and you'll get no errors.

--
harry

(Now Playing: Horde Part 2 - Mnemonists)