Thread View: borland.public.cppbuilder.nativeapi
8 messages
8 total messages
Started by David
Sun, 18 Jun 2006 12:24
Bizzaar problem when calling EnumWindows API function.
Author: David
Date: Sun, 18 Jun 2006 12:24
Date: Sun, 18 Jun 2006 12:24
22 lines
1630 bytes
1630 bytes
Hello
When I use the same module in one project I get the following errors when I
call EnumProc as though it is expecting a different type of function
pointer. But in other projects it is OK. If I cast the function pointer too
what it thinks it expects then things are OK but I shouldn't have to do this
!!What on Earth is going on ??
Thanks in advance
David
BOOL CALLBACK EnumProc(HWND h, LPARAM lp)
{
........
}
EnumWindows(EnumProc,0); // this call causes the error
[C++ Error] App.cpp(91): E2034 Cannot convert 'int (__stdcall *)(void
*,long)' to 'int (__stdcall *)()'
[C++ Error] App.cpp(91): E2342 Type mismatch in parameter 'lpEnumFunc'
(wanted 'int (__stdcall *)()', got 'int (__stdcall *)(void *,long)')
Re: Bizzaar problem when calling EnumWindows API function.
Author: Ed Mulroy
Date: Sun, 18 Jun 2006 13:19
Date: Sun, 18 Jun 2006 13:19
47 lines
2878 bytes
2878 bytes
> EnumWindows(EnumProc,0); // this call causes the error
>
> [C++ Error] App.cpp(91): E2034 Cannot convert 'int (__stdcall *)(void
> *,long)' to 'int (__stdcall *)()'
> [C++ Error] App.cpp(91): E2342 Type mismatch in parameter 'lpEnumFunc'
> (wanted 'int (__stdcall *)()', got 'int (__stdcall *)(void *,long)')
> ...
> !!What on Earth is going on ??
I think that is due to differences in the Windows header files.
Long ago when MS only supported pre-ANSI standard C compiles did not support
type checking of calling arguments. Functions were prototyped without
calling arguments. Later they added C++ which requires that ability but it
broke builds of old, legacy code. To handle that they added the macro
STRICT to cause function prototypes to be more strictly interpreted. Since
Borland must license the MS header files this facility to support a problem
from 16 bit Windows continues to this day.
Try putting this on the first line of the source code file:
#define STRICT
. Ed
> David wrote in message
> news:44954617$1@newsgroups.borland.com...
>
> When I use the same module in one project I get the following errors when
> I call EnumProc as though it is expecting a different type of function
> pointer. But in other projects it is OK. If I cast the function pointer
> too what it thinks it expects then things are OK but I shouldn't have to
> do this !!What on Earth is going on ??
>
> Thanks in advance
> David
>
> BOOL CALLBACK EnumProc(HWND h, LPARAM lp)
> {
> ........
> }
>
> EnumWindows(EnumProc,0); // this call causes the error
>
> [C++ Error] App.cpp(91): E2034 Cannot convert 'int (__stdcall *)(void
> *,long)' to 'int (__stdcall *)()'
> [C++ Error] App.cpp(91): E2342 Type mismatch in parameter 'lpEnumFunc'
> (wanted 'int (__stdcall *)()', got 'int (__stdcall *)(void *,long)')
Re: Bizzaar problem when calling EnumWindows API function.
Author: David
Date: Sun, 18 Jun 2006 14:25
Date: Sun, 18 Jun 2006 14:25
62 lines
3278 bytes
3278 bytes
Thanks
I tried this but still no go.
If I cast the parameter I don't think there will be any problems although I
don't like doing kludges like this :-(
regards
david
"Ed Mulroy" <dont_email_me@bitbuc.ket> wrote in message
news:449552e8$1@newsgroups.borland.com...
>> EnumWindows(EnumProc,0); // this call causes the error
>>
>> [C++ Error] App.cpp(91): E2034 Cannot convert 'int (__stdcall *)(void
>> *,long)' to 'int (__stdcall *)()'
>> [C++ Error] App.cpp(91): E2342 Type mismatch in parameter 'lpEnumFunc'
>> (wanted 'int (__stdcall *)()', got 'int (__stdcall *)(void *,long)')
>> ...
>> !!What on Earth is going on ??
>
> I think that is due to differences in the Windows header files.
>
> Long ago when MS only supported pre-ANSI standard C compiles did not
> support type checking of calling arguments. Functions were prototyped
> without calling arguments. Later they added C++ which requires that
> ability but it broke builds of old, legacy code. To handle that they
> added the macro STRICT to cause function prototypes to be more strictly
> interpreted. Since Borland must license the MS header files this facility
> to support a problem from 16 bit Windows continues to this day.
>
> Try putting this on the first line of the source code file:
> #define STRICT
>
> . Ed
>
>> David wrote in message
>> news:44954617$1@newsgroups.borland.com...
>>
>> When I use the same module in one project I get the following errors when
>> I call EnumProc as though it is expecting a different type of function
>> pointer. But in other projects it is OK. If I cast the function pointer
>> too what it thinks it expects then things are OK but I shouldn't have to
>> do this !!What on Earth is going on ??
>>
>> Thanks in advance
>> David
>>
>> BOOL CALLBACK EnumProc(HWND h, LPARAM lp)
>> {
>> ........
>> }
>>
>> EnumWindows(EnumProc,0); // this call causes the error
>>
>> [C++ Error] App.cpp(91): E2034 Cannot convert 'int (__stdcall *)(void
>> *,long)' to 'int (__stdcall *)()'
>> [C++ Error] App.cpp(91): E2342 Type mismatch in parameter 'lpEnumFunc'
>> (wanted 'int (__stdcall *)()', got 'int (__stdcall *)(void *,long)')
>
>
Re: Bizzaar problem when calling EnumWindows API function.
Author: Ed Mulroy
Date: Sun, 18 Jun 2006 14:42
Date: Sun, 18 Jun 2006 14:42
19 lines
1365 bytes
1365 bytes
Then try changing the first line of the source from #define STRICT to #define STRICT #include <windows.h> . Ed > David wrote in message > news:44956252$1@newsgroups.borland.com... > Thanks > > I tried this but still no go. > > If I cast the parameter I don't think there will be any problems although > I don't like doing kludges like this :-(
Re: Bizzaar problem when calling EnumWindows API function.
Author: Bob Gonder
Date: Sun, 18 Jun 2006 19:47
Date: Sun, 18 Jun 2006 19:47
30 lines
1625 bytes
1625 bytes
David wrote:
>I tried this but still no go.
Look in WINUSER.H
#ifdef STRICT
typedef BOOL (CALLBACK* WNDENUMPROC)(HWND, LPARAM);
#else /* !STRICT */
typedef FARPROC WNDENUMPROC;
#endif
WINUSERAPI
BOOL
WINAPI
EnumWindows(
IN WNDENUMPROC lpEnumFunc,
IN LPARAM lParam);
>>> [C++ Error] App.cpp(91): E2034 Cannot convert 'int (__stdcall *)(void
>>> *,long)' to 'int (__stdcall *)()'
>>> [C++ Error] App.cpp(91): E2342 Type mismatch in parameter 'lpEnumFunc'
>>> (wanted 'int (__stdcall *)()', got 'int (__stdcall *)(void *,long)')
Definately a STRICT problem.
Re: Bizzaar problem when calling EnumWindows API function.
Author: Bob Gonder
Date: Sun, 18 Jun 2006 20:14
Date: Sun, 18 Jun 2006 20:14
19 lines
1436 bytes
1436 bytes
Bob Gonder wrote: >David wrote: > >>I tried this but still no go. > >Look in WINUSER.H > >#ifdef STRICT Another thought is WINDEF.H where it says.... #ifndef NO_STRICT #ifndef STRICT #define STRICT 1 #endif #endif /* NO_STRICT */ So make sure there isn't a NO_STRICT somewhere.
Re: Bizzaar problem when calling EnumWindows API function.
Author: Ed Mulroy
Date: Mon, 19 Jun 2006 00:26
Date: Mon, 19 Jun 2006 00:26
24 lines
1810 bytes
1810 bytes
> So make sure there isn't a NO_STRICT somewhere. FYI: VCL apps seem to have NO_STRICT defined (although a search of the header files doesn't seem to find it). That is why I suggested that he define STRICT himself and do it before the #include list. . Ed > Bob Gonder wrote in message > news:rrcb92dsi5pgljuqp8v69732s6v0t56apm@4ax.com... > >>Look in WINUSER.H >> >>#ifdef STRICT > > Another thought is WINDEF.H where it says.... > > #ifndef NO_STRICT > #ifndef STRICT > #define STRICT 1 > #endif > #endif /* NO_STRICT */ > > So make sure there isn't a NO_STRICT somewhere.
Re: Bizzaar problem when calling EnumWindows API function.
Author: Remy Lebeau (TeamB)
Date: Mon, 19 Jun 2006 02:35
Date: Mon, 19 Jun 2006 02:35
16 lines
1612 bytes
1612 bytes
"Ed Mulroy" <dont_email_me@bitbuc.ket> wrote in message
news:4495ef49$1@newsgroups.borland.com...
> FYI: VCL apps seem to have NO_STRICT defined (although a
> search of the header files doesn't seem to find it). That is why I
> suggested that he define STRICT himself and do it before the
> #include list.
Or just suck in his pride and use the WNDENUMPROC typedef in a cast. Then
it won't matter whether STRICT is defined or not, ie:
EnumWindows((WNDENUMPROC)EnumProc, 0);
Gambit
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