Article View: borland.public.cppbuilder.nativeapi
Article #3482Re: Bizzaar problem when calling EnumWindows API function.
From: 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)')
Technical Details
Message-ID:
<449552e8$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<44954617$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,4e294185b67adeb4 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Ed Mulroy" <dont_email_me@bitbuc.ket> Newsgroups: borland.public.cppbuilder.nativeapi References: <44954617$1@newsgroups.borland.com> Subject: Re: Bizzaar problem when calling EnumWindows API function. Date: Sun, 18 Jun 2006 09:19:16 -0400 Lines: 49 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 69.242.35.97 Message-ID: <449552e8$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1150636776 69.242.35.97 (18 Jun 2006 06:19:36 -0700) X-Authenticated-User: edmulroy Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail