www.delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-Spam-Check-By: | sourceware.org |
From: | "Dave Korn" <dave DOT korn AT artimi DOT com> |
To: | <cygwin AT cygwin DOT com> |
References: | <18613133 DOT post AT talk DOT nabble DOT com> |
Subject: | RE: GetProcAddress Problem |
Date: | Wed, 23 Jul 2008 16:29:46 +0100 |
Message-ID: | <001401c8ecd8$efd601d0$9601a8c0@CAM.ARTIMI.COM> |
MIME-Version: | 1.0 |
X-Mailer: | Microsoft Office Outlook 11 |
In-Reply-To: | <18613133.post@talk.nabble.com> |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Stefano Facchetti wrote on 23 July 2008 16:17: > How specify in FAQ 6.16 I try to compile this code: > > ... > HMODULE h = LoadLibrary("cygwin1.dll"); > void (*init)() = GetProcAddress(h, "cygwin_dll_init"); > init(); > ... > > The compiler give my the following error: > > festivalDll.cc: In function `void festival_init()': > festivalDll.cc:18: error: invalid conversion from `int (*)()' to `void > (*)()' > > How can I do..? GetProcAddress returns all function pointers as if they were of type 'int (*)()', because it has to return a pointer to some kind of function, but it can't know what actual prototype the function has, so it uses the simplest. In your program, where you /know/ the actual type of the function, you need to cast the result returned from GPA: void (*init)() = (void (*)()) GetProcAddress(h, "cygwin_dll_init"); cheers, DaveK -- Can't think of a witty .sigline today.... -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |