diff --git a/mex/sources/ms-sbvar/mex_top_level.cc b/mex/sources/ms-sbvar/mex_top_level.cc
index d2542c4bea06326be606801fcff4f1a7b050832c..7c2f6d56baa7f9b3b6550c692397fd1403438e0d 100644
--- a/mex/sources/ms-sbvar/mex_top_level.cc
+++ b/mex/sources/ms-sbvar/mex_top_level.cc
@@ -48,16 +48,16 @@ mexFunction(int nlhs, mxArray *plhs[],
   /*
    * Allocate memory
    */
-  maxnargs = (int) (mxGetN(prhs[0])/2+1);
-  argument = (char *) mxCalloc(mxGetN(prhs[0])+1, sizeof(char));
-  args = (char **) mxCalloc(maxnargs, sizeof(char *));
+  maxnargs = static_cast<int> (mxGetN(prhs[0])/2+1);
+  argument = static_cast<char *> (mxCalloc(mxGetN(prhs[0])+1, sizeof(char)));
+  args = static_cast<char **> (mxCalloc(maxnargs, sizeof(char *)));
   if (argument == NULL || args == NULL)
     DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: could not allocate memory. (1)");
 
   /*
    * Create argument string from prhs and parse to create args / nargs
    */
-  if (!(args[nargs] = (char *) mxCalloc(strlen(mainarg)+1, sizeof(char))))
+  if (!(args[nargs] = static_cast<char *> (mxCalloc(strlen(mainarg)+1, sizeof(char)))))
     DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: could not allocate memory. (2)");
 
   strncpy(args[nargs++], mainarg, strlen(mainarg));
@@ -68,7 +68,7 @@ mexFunction(int nlhs, mxArray *plhs[],
   beginarg = &argument[0];
   while ((n = strcspn(beginarg, " ")))
     {
-      if (!(args[nargs] = (char *) mxCalloc(n+1, sizeof(char))))
+      if (!(args[nargs] = static_cast<char *> (mxCalloc(n+1, sizeof(char)))))
         DYN_MEX_FUNC_ERR_MSG_TXT("Error in MS-SBVAR MEX file: could not allocate memory. (3)");
 
       strncpy(args[nargs++], beginarg, n);