Re: Compiling GLPK with stdcall calling convention

Heinrich Schuchardt <[email protected]>
Newsgroups gmane.comp.gnu.glpk
Message-ID <[email protected]>
Hello Andrew,

unfortunately you missed one function passed to qsort.

Please, apply the appended patch
https://github.com/xypron/glpk/commit/f6afa4d6645868b8369c757debe8bc8663ec9c7c

Best regards

Heinrich Schuchardt

On 01/08/2017 04:14 PM, Andrew Makhorin wrote:
> Hi Heinrich,
> 
> Thank you for your efforts.
> 
>> for Windows 32 two different calling conventions are used: __cdecl and
>> __stdcall.
>>
>> To use GLPK in conjunction with 32bit LibreOffice (or OpenOffice) Basic
>> it is necessary to compile the GLPK library with __stdcall.
>>
>> Compilation with __stdcall can be achieved by using the /Gz compiler
>> option for Visual Studio Express C++.
>>
>> Unfortunately this is not enough. All functions passed to qsort must use
>> the __cdecl calling convention.
> 
> I'd like just to know why MSVC developers didn't provide a stdcall
> version of the C lib. 
> 
>>
>> On Github I have set up a repository with a patched GLPK 4.60 which
>> allows both compiling with __cdecl and with __stdcall:
>> https://github.com/xypron/glpk/tree/glpk-4.60-stdcall
>>
>> The essential patch is
>> https://github.com/xypron/glpk/commit/471b8ee233da57391b0f4401380c0405f7ab2455
>>
>> It adds a symbol CDECL that is defined in config.h and applied to the
>> relevant comparison functions.
>>
>> I have also added a Makefile and build batch file but these are not
>> essential.
>>
>> Could you, please, consider adding this CDECL symbol to GLPK 4.61.
> 
> Done. Please see
> http://sourceforge.net/projects/noumenon/files/tmp/
> (Note that this is *not* an official release.)
> 
> To avoid defining some macros (i.e. CDECL) on compiling glpk on a
> platform other than GNU/Linux and MS Windows I made the changes in the
> following way:
> 
> #ifndef __WOE__
> int foo(...
> #else
> int __cdecl foo(...
> #endif
> 
> It is always possible to define __cdecl as an empty token sequence, so
> there should be no problem I hope.
> 
> Please check the package with VC10. (I've got only VC9.)
> 
> 
> Best regards,
> 
> Andrew Makhorin
> 
>

_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk
0001-spychuzc.c-add-missing-__cdecl.patch (text/x-patch, 944 B)
From f6afa4d6645868b8369c757debe8bc8663ec9c7c Mon Sep 17 00:00:00 2001
From: Heinrich Schuchardt <[email protected]>
Date: Sun, 8 Jan 2017 16:37:27 +0100
Subject: [PATCH 1/1] spychuzc.c: add missing __cdecl

Signed-off-by: Heinrich Schuchardt <[email protected]>
---
 src/simplex/spychuzc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/simplex/spychuzc.c b/src/simplex/spychuzc.c
index 27a4924..e320f8f 100644
--- a/src/simplex/spychuzc.c
+++ b/src/simplex/spychuzc.c
@@ -501,7 +501,11 @@ int spy_ls_eval_bp(SPXLP *lp, const double d[/*1+n-m*/],
 *  On exit the routine also replaces the parameter slope with a new
 *  value that corresponds to the new last break-point bp[num1]. */
 
+#ifndef __WOE__
 static int fcmp(const void *v1, const void *v2)
+#else
+static int __cdecl fcmp(const void *v1, const void *v2)
+#endif
 {     const SPYBP *p1 = v1, *p2 = v2;
       if (p1->teta < p2->teta)
          return -1;
-- 
2.11.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.