help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-glpk] Adjusting GLPK for stdcall


From: Heinrich Schuchardt
Subject: [Help-glpk] Adjusting GLPK for stdcall
Date: Thu, 5 Jan 2017 22:45:59 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0

On 01/05/2017 09:50 PM, Passorelli, Curtis wrote:
> I have the 4.60 source code. Is there any way to compile it to work
with VBA such as adding Gz to the Make File or changing the source code
to __stdcall?

Hello Curtis,

according to
https://msdn.microsoft.com/en-us/en_us/library/zxk0tw93.aspx
__stdcall is only relevant for 32bit and ignored on the amd64/x64
architecture.

/Gz sets the __stdcall convention for all functions
https://msdn.microsoft.com/en-us/library/46t77ak2.aspx

But the code still has to be changed manually where function pointers
are passed that have to be __cdecl. This was the case when calling qsort
under Visual Studio 2008.

Below you find a summary of the changes needed for 4.37. It is a small
number of places.

I think the best way to do it would be to provide a symbol, e.g. CDECL,
everywhere where compiling with /Gz requires __cdecl. This symbol than
can be defined as __cdecl in w32/config.h and as blank in all other
config.h files.

The patch should be sent to Andrew for integration into his upstream code.

@Andrew
LibreOffice supports calling native DLLs on Windows. The MPL license is
compatible with GPL, cf. https://www.gnu.org/licenses/license-list.html
So there is a legitimate reason for compiling with __stdcall convention.

Best regards

Heinrich Schuchardt

diff -ruN glpk-4.37/src/glpini02.c glpk-4.37-stdcall/src/glpini02.c
--- glpk-4.37/src/glpini02.c    2009-03-29 11:00:00.000000000 +0200
+++ glpk-4.37-stdcall/src/glpini02.c    2010-01-04 19:19:14.815755000 +0100
@@ -31,7 +31,7 @@
       /* penalty value */
 };

-static int fcmp(const void *ptr1, const void *ptr2)
+static int __cdecl fcmp(const void *ptr1, const void *ptr2)
 {     /* this routine is passed to the qsort() function */
       struct var *col1 = (void *)ptr1, *col2 = (void *)ptr2;
       if (col1->q < col2->q) return -1;
diff -ruN glpk-4.37/src/glpios03.c glpk-4.37-stdcall/src/glpios03.c
--- glpk-4.37/src/glpios03.c    2009-03-29 11:00:00.000000000 +0200
+++ glpk-4.37-stdcall/src/glpios03.c    2010-01-04 19:19:14.815755000 +0100
@@ -432,7 +432,7 @@
 #if 0
 struct col { int j; double f; };

-static int fcmp(const void *x1, const void *x2)
+static int __cdecl fcmp(const void *x1, const void *x2)
 {     const struct col *c1 = x1, *c2 = x2;
       if (c1->f > c2->f) return -1;
       if (c1->f < c2->f) return +1;
@@ -1811,7 +1811,7 @@

 struct cut { IOSCUT *cut; double eff; };

-static int fcmp(const void *x1, const void *x2)
+static int __cdecl fcmp(const void *x1, const void *x2)
 {     const struct cut *c1 = x1, *c2 = x2;
       if (c1->eff > c2->eff) return -1;
       if (c1->eff < c2->eff) return +1;
diff -ruN glpk-4.37/src/glpios05.c glpk-4.37-stdcall/src/glpios05.c
--- glpk-4.37/src/glpios05.c    2009-03-29 11:00:00.000000000 +0200
+++ glpk-4.37-stdcall/src/glpios05.c    2010-01-04 19:19:14.815755000 +0100
@@ -225,7 +225,7 @@

 struct var { int j; double f; };

-static int fcmp(const void *p1, const void *p2)
+static int __cdecl fcmp(const void *p1, const void *p2)
 {     const struct var *v1 = p1, *v2 = p2;
       if (v1->f > v2->f) return -1;
       if (v1->f < v2->f) return +1;
diff -ruN glpk-4.37/src/glpios06.c glpk-4.37-stdcall/src/glpios06.c
--- glpk-4.37/src/glpios06.c    2009-03-29 11:00:00.000000000 +0200
+++ glpk-4.37-stdcall/src/glpios06.c    2010-01-04 19:19:14.815755000 +0100
@@ -774,7 +774,7 @@

 struct vset { int j; double v; };

-static int cmir_cmp(const void *p1, const void *p2)
+static int __cdecl cmir_cmp(const void *p1, const void *p2)
 {     const struct vset *v1 = p1, *v2 = p2;
       if (v1->v < v2->v) return -1;
       if (v1->v > v2->v) return +1;
diff -ruN glpk-4.37/src/glpios10.c glpk-4.37-stdcall/src/glpios10.c
--- glpk-4.37/src/glpios10.c    2009-03-29 11:00:00.000000000 +0200
+++ glpk-4.37-stdcall/src/glpios10.c    2010-01-04 19:19:14.815755000 +0100
@@ -54,7 +54,7 @@
       /* sorting key */
 };

-static int fcmp(const void *x, const void *y)
+static int __cdecl fcmp(const void *x, const void *y)
 {     /* comparison routine */
       const struct VAR *vx = x, *vy = y;
       if (vx->d > vy->d)
diff -ruN glpk-4.37/w32/Makefile_VC9_DLL
glpk-4.37-stdcall/w32/Makefile_VC9_DLL
--- glpk-4.37/w32/Makefile_VC9_DLL      2009-03-29 11:00:00.000000000 +0200
+++ glpk-4.37-stdcall/w32/Makefile_VC9_DLL      2010-01-04 19:19:14.815755000
+0100
@@ -1,6 +1,6 @@
 # Build GLPK DLL with Microsoft Visual Studio Express 2008

-CFLAGS = /I. /DHAVE_CONFIG_H /nologo /W3 /O2
+CFLAGS = /I. /DHAVE_CONFIG_H /nologo /W3 /O2 /Gz

 OBJSET = \
 ..\src\glpapi01.obj \




reply via email to

[Prev in Thread] Current Thread [Next in Thread]