Skip to content

Commit 4522cda

Browse files
mattntsahara
authored andcommitted
fix build on VS2012
1 parent 1f3335d commit 4522cda

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

mrbgems/mruby-math/src/math.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
mrb_raise(mrb, E_RANGE_ERROR, "Numerical argument is out of domain - " #msg)
1414

1515
/* math functions not provided by Microsoft Visual C++ 2012 or older */
16-
#if defined _MSC_VER && _MSC_VER < 1800
16+
#if defined _MSC_VER && _MSC_VER <= 1700
1717

1818
#define MATH_TOLERANCE 1E-12
1919

src/dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ write_irep_header(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
3434
{
3535
uint8_t *cur = buf;
3636

37-
cur += uint32_to_bin(get_irep_record_size_1(mrb, irep), cur); /* record size */
37+
cur += uint32_to_bin((uint32_t)get_irep_record_size_1(mrb, irep), cur); /* record size */
3838
cur += uint16_to_bin((uint16_t)irep->nlocals, cur); /* number of local variable */
3939
cur += uint16_to_bin((uint16_t)irep->nregs, cur); /* number of register variable */
4040
cur += uint16_to_bin((uint16_t)irep->rlen, cur); /* number of child irep */

src/string.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
** See Copyright Notice in mruby.h
55
*/
66

7+
#ifdef _MSC_VER
8+
# define _CRT_NONSTDC_NO_DEPRECATE
9+
#endif
10+
711
#include <ctype.h>
812
#include <limits.h>
913
#include <stddef.h>
@@ -1984,12 +1988,12 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int b
19841988
}
19851989
n *= base;
19861990
n += c;
1987-
if (n > (int64_t)MRB_INT_MAX + (sign ? 0 : 1)) {
1991+
if (n > (uint64_t)MRB_INT_MAX + (sign ? 0 : 1)) {
19881992
mrb_raisef(mrb, E_ARGUMENT_ERROR, "string (%S) too big for integer",
19891993
mrb_str_new(mrb, str, pend-str));
19901994
}
19911995
}
1992-
val = n;
1996+
val = (mrb_int)n;
19931997
if (badcheck) {
19941998
if (p == str) goto bad; /* no number */
19951999
while (p<pend && ISSPACE(*p)) p++;

0 commit comments

Comments
 (0)