issue with #include

A

--== Alain ==--

Hi,

Under VC++.NET, i have a stupid issue with #include statement.
Usually when we include some *.h file, we need to declare them before
any #using <> or #using namespace... to avoid issue at compilation time.

However, when i write #include "commctrl.h" as below in my *.h file :

#pragma once
#include "commctrl.h"
#using <mscorlib.dll>

using namespace System;
using namespace System::Windows::Forms;
using namespace System::Drawing;
using namespace System::ComponentModel;
....

i have a lot of errors like :
D:\Program Files\Microsoft Visual Studio
8\VC\PlatformSDK\include\commctrl.h(29) : error C2146: syntax error :
missing ';' before identifier 'HRESULT'
D:\Program Files\Microsoft Visual Studio
8\VC\PlatformSDK\include\commctrl.h(29) : error C4430: missing type
specifier - int assumed. Note: C++ does not support default-int
and so on...

so now, where the problem ?

thanks a lot,
Al.
 
A

--== Alain ==--

Additional information :

I did the following thing in my *.h file :

#pragma once
#include <windows.h>
#include "commctrl.h"
#using <mscorlib.dll>
....
LRESULT hWnd;
hWnd = ::SendMessage((HWND)(this->Handle.ToPointer()), LVM_GETHEADER, 0, 0);

but the linker tells :
RAF_ListView.obj : error LNK2028: unresolved token (0A00004B) "extern
"C" long __stdcall SendMessageW(struct HWND__ *,unsigned int,unsigned
int,long)" (?SendMessageW@@$$J216YGJPAUHWND__@@IIJ@Z) referenced in
function "extern "C" long __cdecl SendMessage(struct HWND__ *,unsigned
int,unsigned int,long)" (?SendMessage@@$$J0YAJPAUHWND__@@IIJ@Z)

and

RAF_ListView.obj : error LNK2019: unresolved external symbol "extern "C"
long __stdcall SendMessageW(struct HWND__ *,unsigned int,unsigned
int,long)" (?SendMessageW@@$$J216YGJPAUHWND__@@IIJ@Z) referenced in
function "extern "C" long __cdecl SendMessage(struct HWND__ *,unsigned
int,unsigned int,long)" (?SendMessage@@$$J0YAJPAUHWND__@@IIJ@Z)

except the stdcall changed by cdecl in the error message, everything is
the same...

where is the problem ?

Al.
 
B

Ben Voigt

--== Alain ==-- said:
Additional information :

I did the following thing in my *.h file :

#pragma once
#include <windows.h>
#include "commctrl.h"
#using <mscorlib.dll>
...
LRESULT hWnd;
hWnd = ::SendMessage((HWND)(this->Handle.ToPointer()), LVM_GETHEADER, 0,
0);

but the linker tells :
RAF_ListView.obj : error LNK2028: unresolved token (0A00004B) "extern "C"
long __stdcall SendMessageW(struct HWND__ *,unsigned int,unsigned
int,long)" (?SendMessageW@@$$J216YGJPAUHWND__@@IIJ@Z) referenced in
function "extern "C" long __cdecl SendMessage(struct HWND__ *,unsigned
int,unsigned int,long)" (?SendMessage@@$$J0YAJPAUHWND__@@IIJ@Z)

and

RAF_ListView.obj : error LNK2019: unresolved external symbol "extern "C"
long __stdcall SendMessageW(struct HWND__ *,unsigned int,unsigned
int,long)" (?SendMessageW@@$$J216YGJPAUHWND__@@IIJ@Z) referenced in
function "extern "C" long __cdecl SendMessage(struct HWND__ *,unsigned
int,unsigned int,long)" (?SendMessage@@$$J0YAJPAUHWND__@@IIJ@Z)

except the stdcall changed by cdecl in the error message, everything is
the same...

where is the problem ?

Al.

You need to link with user32.lib
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top