diff --git a/mex/sources/dynblas.h b/mex/sources/dynblas.h
index be0586b061b45a9545c967e62df6f9f1840c3057..c6d62e3d7395c942593e2aa1fde78f0eee38cd90 100644
--- a/mex/sources/dynblas.h
+++ b/mex/sources/dynblas.h
@@ -8,7 +8,7 @@
  * and MATLAB_VERSION (for version 7.4, define it to 0x0704).
  *
  *
- * Copyright © 2009-2020 Dynare Team
+ * Copyright © 2009-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -29,13 +29,13 @@
 #ifndef _DYNBLAS_H
 #define _DYNBLAS_H
 
-#if defined(MATLAB_MEX_FILE)
+#if defined(MATLAB_MEX_FILE) && __SIZEOF_POINTER__ == 8
 # ifdef __cplusplus
-#  include <cstddef>
+#  include <cstdint>
 # else
-#  include <stddef.h>
+#  include <stdint.h>
 # endif
-typedef ptrdiff_t blas_int;
+typedef int64_t blas_int;
 #else
 typedef int blas_int;
 #endif
diff --git a/mex/sources/dynlapack.h b/mex/sources/dynlapack.h
index 2b95919e0c646e691888bb48792b743312455775..59d394241c9b52c28469c55aa3f6cb38a4286be7 100644
--- a/mex/sources/dynlapack.h
+++ b/mex/sources/dynlapack.h
@@ -8,7 +8,7 @@
  * and MATLAB_VERSION (for version 7.4, define it to 0x0704).
  *
  *
- * Copyright © 2009-2020 Dynare Team
+ * Copyright © 2009-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -29,13 +29,13 @@
 #ifndef _DYNLAPACK_H
 #define _DYNLAPACK_H
 
-#if defined(MATLAB_MEX_FILE)
+#if defined(MATLAB_MEX_FILE) && __SIZEOF_POINTER__ == 8
 # ifdef __cplusplus
-#  include <cstddef>
+#  include <cstdint>
 # else
-#  include <stddef.h>
+#  include <stdint.h>
 # endif
-typedef ptrdiff_t lapack_int;
+typedef int64_t lapack_int;
 #else
 typedef int lapack_int;
 #endif