Ignore:
Timestamp:
2023-03-27T16:20:17+02:00 (14 months ago)
Author:
Per Östlund <perost86@…>
Parents:
02fef0b9
git-author:
Per Östlund <perost86@…> (03/27/23 14:31:47)
git-committer:
Per Östlund <perost86@…> (03/27/23 16:20:17)
Message:

Fix intString/stringInt on 64-bit Windows

  • Change intString to use the PRINT_MMC_SINT_T macro for the format string instead of assuming it's a long, and change to snprintf just to be safe.
  • Change stringInt to use modelica_integer instead of long, and use MODELICA_INT_MIN/MAX instead of INT_MIN/MAX.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • OMCompiler/SimulationRuntime/c/meta/meta_modelica_builtin.c

    rb0b1473 r803631e  
    5050  if (i>=0 && i<=9) /* Small integers are used so much it makes sense to cache them */
    5151    return mmc_strings_len1['0'+i];
    52   sprintf(buffer, "%ld", (long) i);
     52  snprintf(buffer, 22, "%" PRINT_MMC_SINT_T, i);
    5353  res = mmc_mk_scon(buffer);
    5454  MMC_CHECK_STRING(res);
     
    8181modelica_integer nobox_stringInt(threadData_t *threadData,metamodelica_string s)
    8282{
    83   long res;
     83  modelica_integer res;
    8484  char *endptr,*str=MMC_STRINGDATA(s);
    8585  MMC_CHECK_STRING(s);
    8686  errno = 0;
     87#if defined(_WIN64) || defined(__MINGW64__)
     88  res = strtoll(str,&endptr,10);
     89#else
    8790  res = strtol(str,&endptr,10);
     91#endif
    8892  if (errno != 0 || str == endptr)
    8993    MMC_THROW_INTERNAL();
    9094  if (*endptr != '\0')
    9195    MMC_THROW_INTERNAL();
    92   if (res > INT_MAX || res < INT_MIN)
     96  if (res > MODELICA_INT_MAX || res < MODELICA_INT_MIN)
    9397    MMC_THROW_INTERNAL();
    9498  return res;
Note: See TracChangeset for help on using the changeset viewer.