From f962ca2836c1552bc243a1cf0779ed8f3badd370 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Wed, 17 Jun 2015 20:14:32 +0200 Subject: [PATCH] Fix compiler error in C++ strict mode. Fixes a few "deprecated string to char * cast" warnings too. Thanks to Izaak for pointing out this was broken. --- NEWS | 2 ++ chicken.h | 18 +++++++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index 85bf768..8de8e47 100644 --- a/NEWS +++ b/NEWS @@ -67,6 +67,8 @@ - Removed deprecated C_get_argument[_2] and C_get_environment_variable[_2] functions. - C_mutate2 has been deprecated in favor of C_mutate + - chicken.h can be included in C++ programs in strict C++11 mode + without compiler errors on Linux (thanks to "Izaak"). - Foreign function interface - The foreign type specifier "scheme-pointer" now accepts an optional diff --git a/chicken.h b/chicken.h index dd78898..8f8d82e 100644 --- a/chicken.h +++ b/chicken.h @@ -898,7 +898,7 @@ DECL_C_PROC_p0 (128, 1,0,0,0,0,0,0,0) # define C__STR(x) #x # define C__CHECK_panic(a,s,f,l) \ ((a) ? (void)0 : \ - C_panic_hook("Low-level type assertion " s " failed at " f ":" C__STR(l))) + C_panic_hook(C_text("Low-level type assertion " s " failed at " f ":" C__STR(l)))) # define C__CHECK_core(v,a,s,x) \ ({ struct { \ typeof(v) n1; \ @@ -1038,10 +1038,6 @@ DECL_C_PROC_p0 (128, 1,0,0,0,0,0,0,0) # define C_access access # define C_getpid getpid # define C_getenv getenv -# ifdef __linux__ -extern double round(double); -extern double trunc(double); -# endif #else /* provide this file and define C_PROVIDE_LIBC_STUBS if you want to use your own libc-replacements or -wrappers */ @@ -1329,8 +1325,8 @@ extern double trunc(double); #define C_tty_portp(p) C_mk_bool(isatty(fileno(C_port_file(p)))) -#define C_emit_eval_trace_info(x, y, z) C_emit_trace_info2("", x, y, z) -#define C_emit_syntax_trace_info(x, y, z) C_emit_trace_info2("", x, y, z) +#define C_emit_eval_trace_info(x, y, z) C_emit_trace_info2(C_text(""), x, y, z) +#define C_emit_syntax_trace_info(x, y, z) C_emit_trace_info2(C_text(""), x, y, z) /* These expect C_VECTOR_TYPE to be 0: */ #define C_vector_to_structure(v) (C_block_header(v) |= C_STRUCTURE_TYPE, C_SCHEME_UNDEFINED) @@ -2432,14 +2428,14 @@ C_inline C_word C_i_fixnum_max(C_word x, C_word y) C_inline C_word C_fixnum_divide(C_word x, C_word y) { - if(y == C_fix(0)) C_div_by_zero_error("fx/"); + if(y == C_fix(0)) C_div_by_zero_error(C_text("fx/")); return C_u_fixnum_divide(x, y); } C_inline C_word C_fixnum_modulo(C_word x, C_word y) { - if(y == C_fix(0)) C_div_by_zero_error("fxmod"); + if(y == C_fix(0)) C_div_by_zero_error(C_text("fxmod")); return C_u_fixnum_modulo(x, y); } @@ -2476,7 +2472,7 @@ C_a_i_flonum_quotient_checked(C_word **ptr, int c, C_word n1, C_word n2) { double n3 = C_flonum_magnitude(n2); - if(n3 == 0.0) C_div_by_zero_error("fp/?"); + if(n3 == 0.0) C_div_by_zero_error(C_text("fp/?")); return C_flonum(ptr, C_flonum_magnitude(n1) / n3); } @@ -2484,7 +2480,7 @@ C_a_i_flonum_quotient_checked(C_word **ptr, int c, C_word n1, C_word n2) C_inline double C_ub_i_flonum_quotient_checked(double n1, double n2) { - if(n2 == 0.0) C_div_by_zero_error("fp/?"); + if(n2 == 0.0) C_div_by_zero_error(C_text("fp/?")); return n1 / n2; } -- 2.1.4