Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages
Started by Terry
Wed, 12 Mar 2003 02:12
Compiler error
Author: Terry
Date: Wed, 12 Mar 2003 02:12
Date: Wed, 12 Mar 2003 02:12
29 lines
1788 bytes
1788 bytes
I have been staring at this and i just cannot figure out what
is causing the error.
BOOL WINAPI EnumProcs(PROCENUMPROC lpProc, LPARAM lParam)
{
//code
}
BOOL CALLBACK ProcessEnumProc(DWORD dw, WORD w16, LPCSTR lpstr, LPARAM
lParam)
{
// code
}
void __fastcall TForm1::ToolButton1Click(TObject *Sender)
{
EnumProcs(ProcessEnumProc, (LPARAM)ListView1); << the error below
[C++ Error] Unit1.cpp(354): E2034 Cannot convert 'int (__stdcall
*)(unsigned long,unsigned short,const char *,long)' to 'int (__stdcall
*)(unsigned long,unsigned short,char *,long)'
[C++ Error] Unit1.cpp(354): E2342 Type mismatch in parameter 'lpProc'
(wanted 'int (__stdcall *)(unsigned long,unsigned short,char *,long)',
got 'int (__stdcall *)(unsigned long,unsigned short,const char
*,long)')
}
Can anyone see a problem here?
Re: Compiler error
Author: Holy Punk
Date: Tue, 11 Mar 2003 23:34
Date: Tue, 11 Mar 2003 23:34
20 lines
1434 bytes
1434 bytes
"Terry" <terry@helloworld.com> wrote in message
news:3e6e976e$1@newsgroups.borland.com...
> I have been staring at this and i just cannot figure out what
> is causing the error.
> BOOL WINAPI EnumProcs(PROCENUMPROC lpProc, LPARAM lParam)
> {
> //code
> }
>
> BOOL CALLBACK ProcessEnumProc(DWORD dw, WORD w16, LPCSTR lpstr, LPARAM
> lParam)
> {
> // code
> }
Change LPCSTR to LPSTR. By the way, it's always better to use "char*" or
"const char*" explicitly, then such problem wouldn't appear ;).
Best regards,
Holy Punk.
Re: Compiler error
Author: Ed Mulroy [TeamB]
Date: Wed, 12 Mar 2003 02:33
Date: Wed, 12 Mar 2003 02:33
43 lines
2296 bytes
2296 bytes
The error message hinges on the definition of the typedef PROCENUMPROC but
that definition is not shown in the message.
The error message suggests that it is a declaration of a pointer to a
CALLBACK function taking an argument list whose third argument is a char* or
LPSTR but the function whose name was used as the pointer argument in the
code had a third argument of const char* or LPCSTR.
. Ed
> Terry wrote in message
> news:3e6e976e$1@newsgroups.borland.com...
> I have been staring at this and i just cannot figure out what
> is causing the error.
>
> BOOL WINAPI EnumProcs(PROCENUMPROC lpProc,
> LPARAM lParam)
> {
> //code
> }
>
> BOOL CALLBACK ProcessEnumProc(DWORD dw,
> WORD w16, LPCSTR lpstr, LPARAM
> lParam)
> {
> // code
> }
>
> void __fastcall TForm1::ToolButton1Click(TObject *Sender)
> {
> EnumProcs(ProcessEnumProc, (LPARAM)ListView1);
> << the error below
> [C++ Error] Unit1.cpp(354): E2034 Cannot convert
> 'int (__stdcall*)(unsigned long, unsigned short, const char *,long)'
> to
> 'int (__stdcall*)(unsigned long, unsigned short, char *,long)'
>
> [C++ Error] Unit1.cpp(354): E2342 Type mismatch in parameter
> 'lpProc' (wanted
> 'int (__stdcall *)(unsigned long,unsigned short,char *,long)',
> got
> 'int (__stdcall *)(unsigned long,unsigned short,const char *,long)')
> }
Re: Compiler error
Author: Bruce Salzman
Date: Wed, 12 Mar 2003 02:34
Date: Wed, 12 Mar 2003 02:34
10 lines
1261 bytes
1261 bytes
> [C++ Error] Unit1.cpp(354): E2342 Type mismatch in parameter 'lpProc' > (wanted 'int (__stdcall *)(unsigned long,unsigned short,char *,long)', > got 'int (__stdcall *)(unsigned long,unsigned short,const char > *,long)') Apparently, the definition of PROCENUMPROC expects a char* as the third parameter, and you are trying to pass a const char*. HTH, Bruce
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads