--- modules/core/src/hal_internal.cpp.orig	2017-10-23 08:41:12.000000000 -0700
+++ modules/core/src/hal_internal.cpp	2017-12-16 09:06:29.000000000 -0700
@@ -108,9 +108,9 @@
         if(n == 1 && b_step == sizeof(fptype))
         {
             if(typeid(fptype) == typeid(float))
-                sgesv_(&m, &n, (float*)a, &lda, piv, (float*)b, &m, info);
+                sgesv_((__CLPK_integer*)&m, (__CLPK_integer*)&n, (float*)a, (__CLPK_integer*)&lda, (__CLPK_integer*)piv, (float*)b, (__CLPK_integer*)&m, (__CLPK_integer*)info);
             else if(typeid(fptype) == typeid(double))
-                dgesv_(&m, &n, (double*)a, &lda, piv, (double*)b, &m, info);
+                dgesv_((__CLPK_integer*)&m, (__CLPK_integer*)&n, (double*)a, (__CLPK_integer*)&lda, (__CLPK_integer*)piv, (double*)b, (__CLPK_integer*)&m, (__CLPK_integer*)info);
         }
         else
         {
@@ -120,9 +120,9 @@
             transpose(b, ldb, tmpB, m, m, n);
 
             if(typeid(fptype) == typeid(float))
-                sgesv_(&m, &n, (float*)a, &lda, piv, (float*)tmpB, &m, info);
+                sgesv_((__CLPK_integer*)&m, (__CLPK_integer*)&n, (float*)a, (__CLPK_integer*)&lda, (__CLPK_integer*)piv, (float*)tmpB, (__CLPK_integer*)&m, (__CLPK_integer*)info);
             else if(typeid(fptype) == typeid(double))
-                dgesv_(&m, &n, (double*)a, &lda, piv, (double*)tmpB, &m, info);
+                dgesv_((__CLPK_integer*)&m, (__CLPK_integer*)&n, (double*)a, (__CLPK_integer*)&lda, (__CLPK_integer*)piv, (double*)tmpB, (__CLPK_integer*)&m, (__CLPK_integer*)info);
 
             transpose(tmpB, m, b, ldb, n, m);
             delete[] tmpB;
@@ -131,9 +131,9 @@
     else
     {
         if(typeid(fptype) == typeid(float))
-            sgetrf_(&m, &m, (float*)a, &lda, piv, info);
+            sgetrf_((__CLPK_integer*)&m, (__CLPK_integer*)&m, (float*)a, (__CLPK_integer*)&lda, (__CLPK_integer*)piv, (__CLPK_integer*)info);
         else if(typeid(fptype) == typeid(double))
-            dgetrf_(&m, &m, (double*)a, &lda, piv, info);
+            dgetrf_((__CLPK_integer*)&m, (__CLPK_integer*)&m, (double*)a, (__CLPK_integer*)&lda, (__CLPK_integer*)piv, (__CLPK_integer*)info);
     }
 
     if(*info == 0)
@@ -161,9 +161,9 @@
         if(n == 1 && b_step == sizeof(fptype))
         {
             if(typeid(fptype) == typeid(float))
-                sposv_(L, &m, &n, (float*)a, &lda, (float*)b, &m, &lapackStatus);
+                sposv_(L, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (float*)a, (__CLPK_integer*)&lda, (float*)b, (__CLPK_integer*)&m, (__CLPK_integer*)&lapackStatus);
             else if(typeid(fptype) == typeid(double))
-                dposv_(L, &m, &n, (double*)a, &lda, (double*)b, &m, &lapackStatus);
+                dposv_(L, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (double*)a, (__CLPK_integer*)&lda, (double*)b, (__CLPK_integer*)&m, (__CLPK_integer*)&lapackStatus);
         }
         else
         {
@@ -172,9 +172,9 @@
             transpose(b, ldb, tmpB, m, m, n);
 
             if(typeid(fptype) == typeid(float))
-                sposv_(L, &m, &n, (float*)a, &lda, (float*)tmpB, &m, &lapackStatus);
+                sposv_(L, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (float*)a, (__CLPK_integer*)&lda, (float*)tmpB, (__CLPK_integer*)&m, (__CLPK_integer*)&lapackStatus);
             else if(typeid(fptype) == typeid(double))
-                dposv_(L, &m, &n, (double*)a, &lda, (double*)tmpB, &m, &lapackStatus);
+                dposv_(L, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (double*)a, (__CLPK_integer*)&lda, (double*)tmpB, (__CLPK_integer*)&m, (__CLPK_integer*)&lapackStatus);
 
             transpose(tmpB, m, b, ldb, n, m);
             delete[] tmpB;
@@ -183,9 +183,9 @@
     else
     {
         if(typeid(fptype) == typeid(float))
-            spotrf_(L, &m, (float*)a, &lda, &lapackStatus);
+            spotrf_(L, (__CLPK_integer*)&m, (float*)a, (__CLPK_integer*)&lda, (__CLPK_integer*)&lapackStatus);
         else if(typeid(fptype) == typeid(double))
-            dpotrf_(L, &m, (double*)a, &lda, &lapackStatus);
+            dpotrf_(L, (__CLPK_integer*)&m, (double*)a, (__CLPK_integer*)&lda, (__CLPK_integer*)&lapackStatus);
     }
 
     if(lapackStatus == 0) *info = true;
@@ -225,17 +225,17 @@
     }
 
     if(typeid(fptype) == typeid(float))
-        sgesdd_(mode, &m, &n, (float*)a, &lda, (float*)w, (float*)u, &ldu, (float*)vt, &ldv, (float*)&work1, &lwork, iworkBuf, info);
+        sgesdd_(mode, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (float*)a, (__CLPK_integer*)&lda, (float*)w, (float*)u, (__CLPK_integer*)&ldu, (float*)vt, (__CLPK_integer*)&ldv, (float*)&work1, (__CLPK_integer*)&lwork, (__CLPK_integer*)iworkBuf, (__CLPK_integer*)info);
     else if(typeid(fptype) == typeid(double))
-        dgesdd_(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu, (double*)vt, &ldv, (double*)&work1, &lwork, iworkBuf, info);
+        dgesdd_(mode, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (double*)a, (__CLPK_integer*)&lda, (double*)w, (double*)u, (__CLPK_integer*)&ldu, (double*)vt, (__CLPK_integer*)&ldv, (double*)&work1, (__CLPK_integer*)&lwork, (__CLPK_integer*)iworkBuf, (__CLPK_integer*)info);
 
     lwork = (int)round(work1); //optimal buffer size
     fptype* buffer = new fptype[lwork + 1];
 
     if(typeid(fptype) == typeid(float))
-        sgesdd_(mode, &m, &n, (float*)a, &lda, (float*)w, (float*)u, &ldu, (float*)vt, &ldv, (float*)buffer, &lwork, iworkBuf, info);
+        sgesdd_(mode, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (float*)a, (__CLPK_integer*)&lda, (float*)w, (float*)u, (__CLPK_integer*)&ldu, (float*)vt, (__CLPK_integer*)&ldv, (float*)buffer, (__CLPK_integer*)&lwork, (__CLPK_integer*)iworkBuf, (__CLPK_integer*)info);
     else if(typeid(fptype) == typeid(double))
-        dgesdd_(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu, (double*)vt, &ldv, (double*)buffer, &lwork, iworkBuf, info);
+        dgesdd_(mode, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (double*)a, (__CLPK_integer*)&lda, (double*)w, (double*)u, (__CLPK_integer*)&ldu, (double*)vt, (__CLPK_integer*)&ldv, (double*)buffer, (__CLPK_integer*)&lwork, (__CLPK_integer*)iworkBuf, (__CLPK_integer*)info);
 
     if(!(flags & CV_HAL_SVD_NO_UV))
         transpose_square_inplace(vt, ldv, n);
@@ -286,18 +286,18 @@
         if (k == 1 && b_step == sizeof(fptype))
         {
             if (typeid(fptype) == typeid(float))
-                sgels_(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)b, &m, (float*)&work1, &lwork, info);
+                sgels_(mode, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (__CLPK_integer*)&k, (float*)tmpA, (__CLPK_integer*)&ldtmpA, (float*)b, (__CLPK_integer*)&m, (float*)&work1, (__CLPK_integer*)&lwork, (__CLPK_integer*)info);
             else if (typeid(fptype) == typeid(double))
-                dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)b, &m, (double*)&work1, &lwork, info);
+                dgels_(mode, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (__CLPK_integer*)&k, (double*)tmpA, (__CLPK_integer*)&ldtmpA, (double*)b, (__CLPK_integer*)&m, (double*)&work1, (__CLPK_integer*)&lwork, (__CLPK_integer*)info);
 
             lwork = cvRound(work1); //optimal buffer size
             std::vector<fptype> workBufMemHolder(lwork + 1);
             fptype* buffer = &workBufMemHolder.front();
 
             if (typeid(fptype) == typeid(float))
-                sgels_(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)b, &m, (float*)buffer, &lwork, info);
+                sgels_(mode, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (__CLPK_integer*)&k, (float*)tmpA, (__CLPK_integer*)&ldtmpA, (float*)b, (__CLPK_integer*)&m, (float*)buffer, (__CLPK_integer*)&lwork, (__CLPK_integer*)info);
             else if (typeid(fptype) == typeid(double))
-                dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)b, &m, (double*)buffer, &lwork, info);
+                dgels_(mode, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (__CLPK_integer*)&k, (double*)tmpA, (__CLPK_integer*)&ldtmpA, (double*)b, (__CLPK_integer*)&m, (double*)buffer, (__CLPK_integer*)&lwork, (__CLPK_integer*)info);
         }
         else
         {
@@ -307,18 +307,18 @@
             transpose(b, ldb, tmpB, m, m, k);
 
             if (typeid(fptype) == typeid(float))
-                sgels_(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)tmpB, &m, (float*)&work1, &lwork, info);
+                sgels_(mode, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (__CLPK_integer*)&k, (float*)tmpA, (__CLPK_integer*)&ldtmpA, (float*)tmpB, (__CLPK_integer*)&m, (float*)&work1, (__CLPK_integer*)&lwork, (__CLPK_integer*)info);
             else if (typeid(fptype) == typeid(double))
-                dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)tmpB, &m, (double*)&work1, &lwork, info);
+                dgels_(mode, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (__CLPK_integer*)&k, (double*)tmpA, (__CLPK_integer*)&ldtmpA, (double*)tmpB, (__CLPK_integer*)&m, (double*)&work1, (__CLPK_integer*)&lwork, (__CLPK_integer*)info);
 
             lwork = cvRound(work1); //optimal buffer size
             std::vector<fptype> workBufMemHolder(lwork + 1);
             fptype* buffer = &workBufMemHolder.front();
 
             if (typeid(fptype) == typeid(float))
-                sgels_(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)tmpB, &m, (float*)buffer, &lwork, info);
+                sgels_(mode, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (__CLPK_integer*)&k, (float*)tmpA, (__CLPK_integer*)&ldtmpA, (float*)tmpB, (__CLPK_integer*)&m, (float*)buffer, (__CLPK_integer*)&lwork, (__CLPK_integer*)info);
             else if (typeid(fptype) == typeid(double))
-                dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)tmpB, &m, (double*)buffer, &lwork, info);
+                dgels_(mode, (__CLPK_integer*)&m, (__CLPK_integer*)&n, (__CLPK_integer*)&k, (double*)tmpA, (__CLPK_integer*)&ldtmpA, (double*)tmpB, (__CLPK_integer*)&m, (double*)buffer, (__CLPK_integer*)&lwork, (__CLPK_integer*)info);
 
             transpose(tmpB, m, b, ldb, k, m);
         }
@@ -326,18 +326,18 @@
     else
     {
         if (typeid(fptype) == typeid(float))
-            sgeqrf_(&m, &n, (float*)tmpA, &ldtmpA, (float*)dst, (float*)&work1, &lwork, info);
+            sgeqrf_((__CLPK_integer*)&m, (__CLPK_integer*)&n, (float*)tmpA, (__CLPK_integer*)&ldtmpA, (float*)dst, (float*)&work1, (__CLPK_integer*)&lwork, (__CLPK_integer*)info);
         else if (typeid(fptype) == typeid(double))
-            dgeqrf_(&m, &n, (double*)tmpA, &ldtmpA, (double*)dst, (double*)&work1, &lwork, info);
+            dgeqrf_((__CLPK_integer*)&m, (__CLPK_integer*)&n, (double*)tmpA, (__CLPK_integer*)&ldtmpA, (double*)dst, (double*)&work1, (__CLPK_integer*)&lwork, (__CLPK_integer*)info);
 
         lwork = cvRound(work1); //optimal buffer size
         std::vector<fptype> workBufMemHolder(lwork + 1);
         fptype* buffer = &workBufMemHolder.front();
 
         if (typeid(fptype) == typeid(float))
-            sgeqrf_(&m, &n, (float*)tmpA, &ldtmpA, (float*)dst, (float*)buffer, &lwork, info);
+            sgeqrf_((__CLPK_integer*)&m, (__CLPK_integer*)&n, (float*)tmpA, (__CLPK_integer*)&ldtmpA, (float*)dst, (float*)buffer, (__CLPK_integer*)&lwork, (__CLPK_integer*)info);
         else if (typeid(fptype) == typeid(double))
-            dgeqrf_(&m, &n, (double*)tmpA, &ldtmpA, (double*)dst, (double*)buffer, &lwork, info);
+            dgeqrf_((__CLPK_integer*)&m, (__CLPK_integer*)&n, (double*)tmpA, (__CLPK_integer*)&ldtmpA, (double*)dst, (double*)buffer, (__CLPK_integer*)&lwork, (__CLPK_integer*)info);
     }
 
     if (m == n)
