On Sun, Jun 14, 2015 at 11:37:17PM +0200, felix.winkelm...@bevuta.com wrote:
> > It was introduced in changeset fcc7e346c63e24be91337df9a3ad30d0c5360144
> > in December 2009.
> >
>
> I can't recall. Perhaps because of insufficient mathlib support on
> MingW, or for some other obscure reason.
If that was the reason, it can surely be dropped because the GNU check
was replaced by a linux check later.
I've tested on Linux, and the attached patches fix the problem and compile
fine with normal C as well. I also got rid of a few warnings by wrapping
some more static strings in C_text() calls (which does nothing in C mode, but
in C++ mode it will add an explicit cast from string to C_char *).
I vote for also applying this to prerelease, as it is a reasonably
simple change and it fixes a real problem with C++.
Cheers,
Peter
From 9c11206bc89a3760ecc3e5aaa1210ccc32de6817 Mon Sep 17 00:00:00 2001
From: Peter Bex
Date: Wed, 17 Jun 2015 20:19:48 +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 | 42 +++---
2 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/NEWS b/NEWS
index fcb823c..b898bc0 100644
--- a/NEWS
+++ b/NEWS
@@ -91,6 +91,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 04f2cc2..f53fb3d 100644
--- a/chicken.h
+++ b/chicken.h
@@ -944,7 +944,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; \
@@ -1085,10 +1085,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 */
@@ -1401,8 +1397,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)
@@ -2996,7 +2992,7 @@ C_inline C_word C_i_fixnum_gcd(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);
}
@@ -3004,7 +3000,7 @@ C_inline C_word C_fixnum_divide(C_word x, C_word 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");
+C_div_by_zero_error(C_text("fxmod"));
} else {
y = C_unfix(y);
x = C_unfix(x) % y;
@@ -3020,7 +3016,7 @@ C_inline C_word
C_a_i_fixnum_quotient_checked(C_word **ptr, int c, C_word x, C_word y)
{
if (y == C_fix(0)) {
-C_div_by_zero_error("fx/");
+C_div_by_zero_error(C_text("fx/"));
} else if (x == C_fix(C_MOST_NEGATIVE_FIXNUM) && y == C_fix(-1)) {
return C_bignum1(ptr, 0, -C_MOST_NEGATIVE_FIXNUM); /* Special case */
} else {
@@ -3031,7 +3027,7 @@ C_a_i_fixnum_quotient_checked(C_word **ptr, int c, C_word x, C_word y)
C_inline C_word C_i_fixnum_remainder_checked(C_word x, C_word y)
{
if (y == C_fix(0)) {
-C_div_by_zero_error("fxrem");
+C_div_by_zero_error(C_text("fxrem"));
} else {
x = C_unfix(x);
y = C_unfix(y);
@@ -3068,7 +3064,7 @@ C_inline C_word C_s_a_u_i_integer_abs(C_word **ptr, C_word n, C_word x)
C_inline C_word C_i_fixnum_bit_setp(C_word n, C_word i)
{
if (i & C_INT_SIGN_BIT) {
- C_not_an_uinteger_error("bit-set?", i);
+ C_not_an_uinteger_error(C_tex