made the code work with g++ and without warnings

Fri, 12 Oct 2012 12:46:54 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 12 Oct 2012 12:46:54 +0200
changeset 74
dc8bade7f2a3
parent 73
f15c7d6aebb9
child 75
990734f548ef

made the code work with g++ and without warnings

test/string_tests.c file | annotate | diff | comparison | revisions
ucx/string.h file | annotate | diff | comparison | revisions
--- a/test/string_tests.c	Fri Oct 12 12:12:59 2012 +0200
+++ b/test/string_tests.c	Fri Oct 12 12:46:54 2012 +0200
@@ -5,8 +5,8 @@
 #include "string_tests.h"
 
 UCX_TEST_IMPLEMENT(test_sstr) {
-    sstr_t s1 = sstr("1234");
-    sstr_t s2 = sstrn("ab", 2);
+    sstr_t s1 = sstr((char*)"1234");
+    sstr_t s2 = sstrn((char*)"ab", 2);
     
     UCX_TEST_BEGIN
     
@@ -17,9 +17,9 @@
 }
 
 UCX_TEST_IMPLEMENT(test_sstr_len_cat) {
-    sstr_t s1 = sstr("1234");
-    sstr_t s2 = sstr(".:.:.");
-    sstr_t s3 = sstr("X");
+    sstr_t s1 = S("1234");
+    sstr_t s2 = S(".:.:.");
+    sstr_t s3 = S("X");
     
     sstr_t cat;
     
@@ -54,7 +54,7 @@
 UCX_TEST_IMPLEMENT(test_sstrsplit) {
 
     const char *original = "this,is,a,csv,string";
-    sstr_t test = sstr("this,is,a,csv,string"); /* use copy of original here */
+    sstr_t test = S("this,is,a,csv,string"); /* use copy of original here */
     size_t n;
     sstr_t *list;
 
--- a/ucx/string.h	Fri Oct 12 12:12:59 2012 +0200
+++ b/ucx/string.h	Fri Oct 12 12:46:54 2012 +0200
@@ -12,8 +12,8 @@
 #include <stddef.h>
 
 /* use macros for literals only */
-#define S(s) { s, sizeof(s)-1 }
-#define ST(s) sstrn(s, sizeof(s)-1)
+#define S(s) { (char*)s, sizeof(s)-1 }
+#define ST(s) sstrn((char*)s, sizeof(s)-1)
 
 #ifdef	__cplusplus
 extern "C" {

mercurial