C++ compatibility

diff --git a/skeletons/OCTET_STRING.c b/skeletons/OCTET_STRING.c
index 5034e42..d1b0874 100644
--- a/skeletons/OCTET_STRING.c
+++ b/skeletons/OCTET_STRING.c
@@ -135,7 +135,7 @@
 		nel->got = 0;
 		/* Retain the nel->cont_level, it's correct. */
 	} else {
-		(void *)nel = CALLOC(1, sizeof(struct _stack_el));
+		nel = (struct _stack_el *)CALLOC(1, sizeof(struct _stack_el));
 		if(nel == NULL)
 			return NULL;
 	
@@ -187,7 +187,8 @@
 	 * Create the string if does not exist.
 	 */
 	if(st == NULL) {
-		(void *)st = *os_structure = CALLOC(1, specs->struct_size);
+		*os_structure = CALLOC(1, specs->struct_size);
+		st = (BIT_STRING_t *)*os_structure;
 		if(st == NULL)
 			RETURN(RC_FAIL);
 	}
@@ -212,7 +213,7 @@
 			 */
 			ctx->ptr = _new_stack();
 			if(ctx->ptr) {
-				(void *)stck = ctx->ptr;
+				stck = (struct _stack *)ctx->ptr;
 			} else {
 				RETURN(RC_FAIL);
 			}
@@ -234,7 +235,7 @@
 		/*
 		 * Fill the stack with expectations.
 		 */
-		(void *)stck = ctx->ptr;
+		stck = (struct _stack *)ctx->ptr;
 		sel = stck->cur_ptr;
 	  do {
 		ber_tlv_tag_t tlv_tag;
@@ -409,7 +410,7 @@
 		NEXT_PHASE(ctx);
 		/* Fall through */
 	case 2:
-		(void *)stck = ctx->ptr;
+		stck = (struct _stack *)ctx->ptr;
 		sel = stck->cur_ptr;
 		ASN_DEBUG("Phase 2: Need %ld bytes, size=%ld, alrg=%ld, wn=%d",
 			(long)sel->left, (long)size, (long)sel->got,
diff --git a/skeletons/asn-decoder-template.c b/skeletons/asn-decoder-template.c
index aa893fb..ba719e5 100644
--- a/skeletons/asn-decoder-template.c
+++ b/skeletons/asn-decoder-template.c
@@ -192,7 +192,7 @@
 		size_t newsize = (buf_size << 2) + bySize;
 		void *p = realloc(buffer, newsize);
 		if(p) {
-			buffer = p;
+			buffer = (char *)p;
 			buf_size = newsize;
 
 			DEBUG("\tBuffer reallocated to %ld", (long)newsize);
@@ -228,7 +228,7 @@
 
 	/* prepare the file buffer */
 	if(fbuf_size != suggested_bufsize) {
-		fbuf = realloc(fbuf, suggested_bufsize);
+		fbuf = (char *)realloc(fbuf, suggested_bufsize);
 		if(!fbuf) {
 			perror("realloc()");
 			exit(EX_OSERR);
diff --git a/skeletons/der_encoder.c b/skeletons/der_encoder.c
index b2763c7..62ad757 100644
--- a/skeletons/der_encoder.c
+++ b/skeletons/der_encoder.c
@@ -36,7 +36,7 @@
 	size_t left;
 } enc_to_buf_arg;
 static int encode_to_buffer_cb(const void *buffer, size_t size, void *key) {
-	enc_to_buf_arg *arg = key;
+	enc_to_buf_arg *arg = (enc_to_buf_arg *)key;
 
 	if(arg->left < size)
 		return -1;	/* Data exceeds the available buffer size */
@@ -64,7 +64,7 @@
 		struct_ptr,	/* Pointer to the destination structure */
 		0, 0, encode_to_buffer_cb, &arg);
 	if(ec.encoded != -1) {
-		assert(ec.encoded == (*buffer_size - arg.left));
+		assert(ec.encoded == (ssize_t)(*buffer_size - arg.left));
 		/* Return the encoded contents size */
 		*buffer_size = ec.encoded;
 	}