C++ compatibility

diff --git a/skeletons/BIT_STRING.c b/skeletons/BIT_STRING.c
index 1646929..ef5bd0a 100644
--- a/skeletons/BIT_STRING.c
+++ b/skeletons/BIT_STRING.c
@@ -32,7 +32,7 @@
 int
 BIT_STRING_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
-	const BIT_STRING_t *st = sptr;
+	const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
 
 	if(st && st->buf) {
 		if(st->size) {
@@ -61,7 +61,7 @@
 		asn_app_consume_bytes_f *cb, void *app_key) {
 	static const char *h2c = "0123456789ABCDEF";
 	char scratch[64];
-	const BIT_STRING_t *st = sptr;
+	const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
 	uint8_t *buf;
 	uint8_t *end;
 	char *p = scratch;
diff --git a/skeletons/BMPString.c b/skeletons/BMPString.c
index 93584c8..d914168 100644
--- a/skeletons/BMPString.c
+++ b/skeletons/BMPString.c
@@ -32,7 +32,7 @@
 int
 BMPString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 		asn_app_consume_bytes_f *cb, void *app_key) {
-	const BMPString_t *st = sptr;
+	const BMPString_t *st = (const BMPString_t *)sptr;
 	uint16_t *wchar;
 	uint16_t *wend;
 	char scratch[128];			/* Scratchpad buffer */
diff --git a/skeletons/BOOLEAN.c b/skeletons/BOOLEAN.c
index 209235d..eb89c9c 100644
--- a/skeletons/BOOLEAN.c
+++ b/skeletons/BOOLEAN.c
@@ -32,14 +32,14 @@
 BOOLEAN_decode_ber(asn1_TYPE_descriptor_t *td,
 		void **bool_structure, void *buf_ptr, size_t size,
 		int tag_mode) {
-	BOOLEAN_t *st = *bool_structure;
+	BOOLEAN_t *st = (BOOLEAN_t *)*bool_structure;
 	ber_dec_rval_t rval;
 	ber_dec_ctx_t ctx = { 0, 0, 0, 0 };
 	ber_tlv_len_t length;
 	ber_tlv_len_t lidx;
 
 	if(st == NULL) {
-		st = *bool_structure = CALLOC(1, sizeof(*st));
+		(void *)st = *bool_structure = CALLOC(1, sizeof(*st));
 		if(st == NULL) {
 			rval.code = RC_FAIL;
 			rval.consumed = 0;
@@ -96,7 +96,7 @@
 	int tag_mode, ber_tlv_tag_t tag,
 	asn_app_consume_bytes_f *cb, void *app_key) {
 	der_enc_rval_t erval;
-	BOOLEAN_t *st = sptr;
+	BOOLEAN_t *st = (BOOLEAN_t *)sptr;
 
 	erval.encoded = der_write_tags(td, 1, tag_mode, tag, cb, app_key);
 	if(erval.encoded == -1) {
@@ -127,7 +127,7 @@
 int
 BOOLEAN_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 	asn_app_consume_bytes_f *cb, void *app_key) {
-	const BOOLEAN_t *st = sptr;
+	const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c
index 99f2e72..c65d296 100644
--- a/skeletons/GeneralizedTime.c
+++ b/skeletons/GeneralizedTime.c
@@ -49,7 +49,7 @@
 int
 GeneralizedTime_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
-	const GeneralizedTime_t *st = sptr;
+	const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr;
 	time_t tloc;
 
 	errno = EPERM;			/* Just an unlikely error code */
@@ -67,7 +67,7 @@
 GeneralizedTime_encode_der(asn1_TYPE_descriptor_t *td, void *ptr,
 	int tag_mode, ber_tlv_tag_t tag,
 	asn_app_consume_bytes_f *cb, void *app_key) {
-	GeneralizedTime_t *st = ptr;
+	GeneralizedTime_t *st = (GeneralizedTime_t *)ptr;
 	der_enc_rval_t erval;
 
 	/* If not canonical DER, re-encode into canonical DER. */
@@ -107,7 +107,7 @@
 int
 GeneralizedTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 	asn_app_consume_bytes_f *cb, void *app_key) {
-	const GeneralizedTime_t *st = sptr;
+	const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
@@ -390,7 +390,7 @@
 	}
 
 	/* Pre-allocate a buffer of sufficient yet small length */
-	buf = MALLOC(buf_size);
+	(void *)buf = MALLOC(buf_size);
 	if(!buf) return 0;
 
 	gmtoff = GMTOFF(*tm);
@@ -433,7 +433,7 @@
 		if(opt_gt->buf)
 			FREEMEM(opt_gt->buf);
 	} else {
-		opt_gt = CALLOC(1, sizeof *opt_gt);
+		(void *)opt_gt = CALLOC(1, sizeof *opt_gt);
 		if(!opt_gt) { free(buf); return 0; }
 	}
 
diff --git a/skeletons/IA5String.c b/skeletons/IA5String.c
index 902de85..7fcb194 100644
--- a/skeletons/IA5String.c
+++ b/skeletons/IA5String.c
@@ -29,7 +29,7 @@
 int
 IA5String_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
-	const IA5String_t *st = sptr;
+	const IA5String_t *st = (const IA5String_t *)sptr;
 
 	if(st && st->buf) {
 		uint8_t *buf = st->buf;
diff --git a/skeletons/INTEGER.c b/skeletons/INTEGER.c
index 1af06c7..9cf146e 100644
--- a/skeletons/INTEGER.c
+++ b/skeletons/INTEGER.c
@@ -33,7 +33,7 @@
 ber_dec_rval_t
 INTEGER_decode_ber(asn1_TYPE_descriptor_t *td,
 	void **int_structure, void *buf_ptr, size_t size, int tag_mode) {
-	INTEGER_t *st = *int_structure;
+	INTEGER_t *st = (INTEGER_t *)*int_structure;
 	ber_dec_rval_t rval;
 	ber_dec_ctx_t ctx = { 0, 0, 0, 0 };
 	ber_tlv_len_t length;
@@ -42,7 +42,7 @@
 	 * If the structure is not there, allocate it.
 	 */
 	if(st == NULL) {
-		st = *int_structure = CALLOC(1, sizeof(*st));
+		(void *)st = *int_structure = CALLOC(1, sizeof(*st));
 		if(st == NULL) {
 			rval.code = RC_FAIL;
 			rval.consumed = 0;
@@ -74,7 +74,7 @@
 		return rval;
 	}
 
-	st->buf = MALLOC(length);
+	st->buf = (uint8_t *)MALLOC(length);
 	if(st->buf) {
 		st->size = length;
 	} else {
@@ -103,7 +103,7 @@
 	int tag_mode, ber_tlv_tag_t tag,
 	asn_app_consume_bytes_f *cb, void *app_key) {
 	der_enc_rval_t erval;
-	INTEGER_t *st = ptr;
+	INTEGER_t *st = (INTEGER_t *)ptr;
 
 	ASN_DEBUG("%s %s as INTEGER (tm=%d)",
 		cb?"Encoding":"Estimating", sd->name, tag_mode);
@@ -187,7 +187,7 @@
 INTEGER_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 	asn_app_consume_bytes_f *cb, void *app_key) {
 	char scratch[32];	/* Enough for 64-bit integer */
-	const INTEGER_t *st = sptr;
+	const INTEGER_t *st = (const INTEGER_t *)sptr;
 	uint8_t *buf = st->buf;
 	uint8_t *buf_end = st->buf + st->size;
 	signed long accum;
@@ -249,7 +249,7 @@
 
 void
 INTEGER_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
-	INTEGER_t *st = ptr;
+	INTEGER_t *st = (INTEGER_t *)ptr;
 
 	if(!td || !st)
 		return;
diff --git a/skeletons/NativeInteger.c b/skeletons/NativeInteger.c
index 3dce02f..ca29049 100644
--- a/skeletons/NativeInteger.c
+++ b/skeletons/NativeInteger.c
@@ -40,7 +40,7 @@
 ber_dec_rval_t
 NativeInteger_decode_ber(asn1_TYPE_descriptor_t *td,
 	void **int_ptr, void *buf_ptr, size_t size, int tag_mode) {
-	int *Int = *int_ptr;
+	int *Int = (int *)*int_ptr;
 	ber_dec_rval_t rval;
 	ber_dec_ctx_t ctx = { 0, 0, 0, 0 };
 	ber_tlv_len_t length;
@@ -49,7 +49,7 @@
 	 * If the structure is not there, allocate it.
 	 */
 	if(Int == NULL) {
-		Int = *int_ptr = CALLOC(1, sizeof(*Int));
+		(void *)Int = *int_ptr = CALLOC(1, sizeof(*Int));
 		if(Int == NULL) {
 			rval.code = RC_FAIL;
 			rval.consumed = 0;
@@ -89,7 +89,7 @@
 	{
 		INTEGER_t tmp;
 		long l;
-		tmp.buf = buf_ptr;
+		tmp.buf = (uint8_t *)buf_ptr;
 		tmp.size = length;
 
 		if(asn1_INTEGER2long(&tmp, &l)) {
@@ -165,7 +165,7 @@
 int
 NativeInteger_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 	asn_app_consume_bytes_f *cb, void *app_key) {
-	const int *Int = sptr;
+	const int *Int = (const int *)sptr;
 	char scratch[32];	/* Enough for 64-bit int */
 	int ret;
 
diff --git a/skeletons/NumericString.c b/skeletons/NumericString.c
index ba58923..0bb86db 100644
--- a/skeletons/NumericString.c
+++ b/skeletons/NumericString.c
@@ -29,7 +29,7 @@
 int
 NumericString_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
-	const NumericString_t *st = sptr;
+	const NumericString_t *st = (const NumericString_t *)sptr;
 
 	if(st && st->buf) {
 		uint8_t *buf = st->buf;
diff --git a/skeletons/OBJECT_IDENTIFIER.c b/skeletons/OBJECT_IDENTIFIER.c
index 20de2f6..b428aca 100644
--- a/skeletons/OBJECT_IDENTIFIER.c
+++ b/skeletons/OBJECT_IDENTIFIER.c
@@ -38,7 +38,7 @@
 	int tag_mode, ber_tlv_tag_t tag,
 	asn_app_consume_bytes_f *cb, void *app_key) {
 	der_enc_rval_t erval;
-	OBJECT_IDENTIFIER_t *st = ptr;
+	OBJECT_IDENTIFIER_t *st = (OBJECT_IDENTIFIER_t *)ptr;
 
 	ASN_DEBUG("%s %s as OBJECT IDENTIFIER (tm=%d)",
 		cb?"Encoding":"Estimating", sd->name, tag_mode);
@@ -75,7 +75,7 @@
 int
 OBJECT_IDENTIFIER_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
-	const OBJECT_IDENTIFIER_t *st = sptr;
+	const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
 
 	if(st && st->buf) {
 		if(st->size < 1) {
@@ -231,7 +231,7 @@
 int
 OBJECT_IDENTIFIER_print(asn1_TYPE_descriptor_t *td, const void *sptr,
 	int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
-	const OBJECT_IDENTIFIER_t *st = sptr;
+	const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
 	int startn;
 	int add = 0;
 	int i;
@@ -372,7 +372,7 @@
 
 	if(isLittleEndian && !prepared_order) {
 		uint8_t *a = (unsigned char *)arcval + arcval_size - 1;
-		uint8_t *aend = arcval;
+		uint8_t *aend = (uint8_t *)arcval;
 		uint8_t *msb = buffer + arcval_size - 1;
 		for(tp = buffer; a >= aend; tp++, a--)
 			if((*tp = *a) && (tp < msb))
@@ -382,7 +382,7 @@
 	} else {
 		/* Look for most significant non-zero byte */
 		tend = (unsigned char *)arcval + arcval_size;
-		for(tp = arcval; tp < tend - 1; tp++)
+		for(tp = (uint8_t *)arcval; tp < tend - 1; tp++)
 			if(*tp) break;
 	}
 
@@ -461,7 +461,7 @@
 			unsigned char *ps, *pe;
 			/* If more significant bytes are present,
 			 * make them > 255 quick */
-			for(ps = arcs, pe = ps+arc_type_size - 1; ps < pe; ps++)
+			for(ps = (unsigned char *)arcs, pe = ps+arc_type_size - 1; ps < pe; ps++)
 				arc0 |= *ps, arc1 |= *(ps + arc_type_size);
 			arc0 = *((unsigned char *)arcs + arc_type_size - 1);
 			arc1 = *((unsigned char *)arcs +(arc_type_size<< 1)-1);
@@ -499,7 +499,7 @@
 	 * 	* the value of the first arc which is in range (0..2)
 	 */
 	size = ((arc_type_size * CHAR_BIT + 6) / 7) * arc_slots;
-	bp = buf = MALLOC(size + 1);
+	bp = buf = (uint8_t *)MALLOC(size + 1);
 	if(!buf) {
 		/* ENOMEM */
 		return -1;
@@ -534,7 +534,7 @@
 			uint8_t *a1 = (unsigned char *)arcs + arc_type_size - 1;
 			for(; a1 > aend; fv++, a1--) *fv = *a1;
 		} else {
-			uint8_t *a1 = arcs;
+			uint8_t *a1 = (uint8_t *)arcs;
 			uint8_t *aend = a1 + arc_type_size;
 			for(; a1 < aend; fv++, a1++) *fv = *a1;
 		}
diff --git a/skeletons/OCTET_STRING.c b/skeletons/OCTET_STRING.c
index d5b28c3..e246314 100644
--- a/skeletons/OCTET_STRING.c
+++ b/skeletons/OCTET_STRING.c
@@ -57,7 +57,7 @@
 				while(_ns <= (size_t)(st->size + bufsize));	\
 			ptr = REALLOC(st->buf, _ns);			\
 			if(ptr) {					\
-				st->buf = ptr;				\
+				st->buf = (uint8_t *)ptr;		\
 				ctx->step = _ns;			\
 			} else {					\
 				RETURN(RC_FAIL);			\
@@ -100,7 +100,7 @@
 		nel->want_nulls = 0;
 		nel->bits_chopped = 0;
 	} else {
-		nel = CALLOC(1, sizeof(struct _stack_el));
+		(void *)nel = CALLOC(1, sizeof(struct _stack_el));
 		if(nel == NULL)
 			return NULL;
 	
@@ -119,7 +119,7 @@
 static struct _stack *
 _new_stack() {
 	struct _stack *st;
-	st = CALLOC(1, sizeof(struct _stack));
+	(void *)st = CALLOC(1, sizeof(struct _stack));
 	if(st == NULL)
 		return NULL;
 
@@ -138,7 +138,7 @@
 ber_dec_rval_t
 OCTET_STRING_decode_ber(asn1_TYPE_descriptor_t *td,
 	void **os_structure, void *buf_ptr, size_t size, int tag_mode) {
-	OCTET_STRING_t *st = *os_structure;
+	OCTET_STRING_t *st = (OCTET_STRING_t *)*os_structure;
 	ber_dec_rval_t rval;
 	ber_dec_ctx_t *ctx;
 	ssize_t consumed_myself = 0;
@@ -160,7 +160,7 @@
 	 * Create the string if does not exist.
 	 */
 	if(st == NULL) {
-		st = *os_structure = CALLOC(1, sizeof(*st));
+		(void *)st = *os_structure = CALLOC(1, sizeof(*st));
 		if(st == NULL)
 			RETURN(RC_FAIL);
 	}
@@ -189,7 +189,7 @@
 			 */
 			ctx->ptr = _new_stack();
 			if(ctx->ptr) {
-				stck = ctx->ptr;
+				(void *)stck = ctx->ptr;
 				if(ctx->left < 0) {
 					stck->cur_ptr->want_nulls = -ctx->left;
 					stck->cur_ptr->left = -1;
@@ -223,7 +223,7 @@
 		/*
 		 * Fill the stack with expectations.
 		 */
-		stck = ctx->ptr;
+		(void *)stck = ctx->ptr;
 		sel = stck->cur_ptr;
 	  do {
 		ber_tlv_tag_t tlv_tag;
@@ -307,7 +307,7 @@
 		NEXT_PHASE(ctx);
 		/* Fall through */
 	case 2:
-		stck = ctx->ptr;
+		(void *)stck = ctx->ptr;
 		sel = stck->cur_ptr;
 		ASN_DEBUG("Phase 2: Need %ld bytes, size=%ld",
 			(long)sel->left, (long)size);
@@ -391,7 +391,7 @@
 	int tag_mode, ber_tlv_tag_t tag,
 	asn_app_consume_bytes_f *cb, void *app_key) {
 	der_enc_rval_t erval;
-	OCTET_STRING_t *st = ptr;
+	OCTET_STRING_t *st = (OCTET_STRING_t *)ptr;
 	int add_byte = 0;
 
 	ASN_DEBUG("%s %s as OCTET STRING",
@@ -458,7 +458,7 @@
 OCTET_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 	asn_app_consume_bytes_f *cb, void *app_key) {
 	static const char *h2c = "0123456789ABCDEF";
-	const OCTET_STRING_t *st = sptr;
+	const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
 	char scratch[16 * 3 + 4];
 	char *p = scratch;
 	uint8_t *buf;
@@ -495,7 +495,7 @@
 int
 OCTET_STRING_print_ascii(asn1_TYPE_descriptor_t *td, const void *sptr,
 		int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
-	const OCTET_STRING_t *st = sptr;
+	const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
@@ -509,8 +509,8 @@
 
 void
 OCTET_STRING_free(asn1_TYPE_descriptor_t *td, void *sptr, int contents_only) {
-	OCTET_STRING_t *st = sptr;
-	struct _stack *stck = st->_ber_dec_ctx.ptr;
+	OCTET_STRING_t *st = (OCTET_STRING_t *)sptr;
+	struct _stack *stck = (struct _stack *)st->_ber_dec_ctx.ptr;
 
 	if(!td || !st)
 		return;
@@ -569,7 +569,7 @@
 	if(buf == NULL) {
 		return -1;
 	} else {
-		st->buf = buf;
+		st->buf = (uint8_t *)buf;
 		st->size = len;
 	}
 
@@ -583,7 +583,7 @@
 OCTET_STRING_new_fromBuf(const char *str, int len) {
 	OCTET_STRING_t *st;
 
-	st = CALLOC(1, sizeof(*st));
+	(void *)st = CALLOC(1, sizeof(*st));
 	if(st && str && OCTET_STRING_fromBuf(st, str, len)) {
 		free(st);
 		st = NULL;
diff --git a/skeletons/PrintableString.c b/skeletons/PrintableString.c
index 8589bd2..5c9a1fb 100644
--- a/skeletons/PrintableString.c
+++ b/skeletons/PrintableString.c
@@ -52,7 +52,7 @@
 int
 PrintableString_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
-	const PrintableString_t *st = sptr;
+	const PrintableString_t *st = (const PrintableString_t *)sptr;
 
 	if(st && st->buf) {
 		uint8_t *buf = st->buf;
diff --git a/skeletons/RELATIVE-OID.c b/skeletons/RELATIVE-OID.c
index de0a7c3..eaf98b1 100644
--- a/skeletons/RELATIVE-OID.c
+++ b/skeletons/RELATIVE-OID.c
@@ -32,7 +32,7 @@
 int
 RELATIVE_OID_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 	asn_app_consume_bytes_f *cb, void *app_key) {
-	const RELATIVE_OID_t *st = sptr;
+	const RELATIVE_OID_t *st = (const RELATIVE_OID_t *)sptr;
 	int startn;
 	int i;
 
@@ -112,7 +112,7 @@
 	 * Roughly estimate the maximum size necessary to encode these arcs.
 	 */
 	size = ((arc_type_size * CHAR_BIT + 6) / 7) * arcs_slots;
-	bp = buf = MALLOC(size + 1);
+	bp = buf = (uint8_t *)MALLOC(size + 1);
 	if(!buf) {
 		/* ENOMEM */
 		return -1;
diff --git a/skeletons/UTCTime.c b/skeletons/UTCTime.c
index c02e9f7..e15cca9 100644
--- a/skeletons/UTCTime.c
+++ b/skeletons/UTCTime.c
@@ -40,7 +40,7 @@
 int
 UTCTime_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
-	const UTCTime_t *st = sptr;
+	const UTCTime_t *st = (const UTCTime_t *)sptr;
 	time_t tloc;
 
 	errno = EPERM;			/* Just an unlikely error code */
@@ -57,7 +57,7 @@
 int
 UTCTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 		asn_app_consume_bytes_f *cb, void *app_key) {
-	const UTCTime_t *st = sptr;
+	const UTCTime_t *st = (const UTCTime_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
diff --git a/skeletons/UTF8String.c b/skeletons/UTF8String.c
index 4ec15b8..6b40b25 100644
--- a/skeletons/UTF8String.c
+++ b/skeletons/UTF8String.c
@@ -39,7 +39,8 @@
 UTF8String_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
 	ssize_t len;
-	len = UTF8String_length(sptr, td->name, app_errlog, app_key);
+	len = UTF8String_length((const UTF8String_t *)sptr, td->name,
+		app_errlog, app_key);
 	if(len > 0) len = 0;
 	return len;
 }
@@ -103,7 +104,7 @@
 int
 UTF8String_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 	asn_app_consume_bytes_f *cb, void *app_key) {
-	const UTF8String_t *st = sptr;
+	const UTF8String_t *st = (const UTF8String_t *)sptr;
 
 	(void)td;	/* Unused argument */
 	(void)ilevel;	/* Unused argument */
diff --git a/skeletons/UniversalString.c b/skeletons/UniversalString.c
index 1e3444e..241fe67 100644
--- a/skeletons/UniversalString.c
+++ b/skeletons/UniversalString.c
@@ -30,7 +30,7 @@
 int
 UniversalString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 	asn_app_consume_bytes_f *cb, void *app_key) {
-	const UniversalString_t *st = sptr;
+	const UniversalString_t *st = (const UniversalString_t *)sptr;
 	uint32_t *wchar;
 	uint32_t *wend;
 	char scratch[128];			/* Scratchpad buffer */
diff --git a/skeletons/VisibleString.c b/skeletons/VisibleString.c
index 4a335a3..ad0426e 100644
--- a/skeletons/VisibleString.c
+++ b/skeletons/VisibleString.c
@@ -52,7 +52,7 @@
 int
 VisibleString_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
-	const VisibleString_t *st = sptr;
+	const VisibleString_t *st = (const VisibleString_t *)sptr;
 
 	if(st && st->buf) {
 		uint8_t *buf = st->buf;
diff --git a/skeletons/asn_SEQUENCE_OF.c b/skeletons/asn_SEQUENCE_OF.c
index 71f6f0c..7cfd45f 100644
--- a/skeletons/asn_SEQUENCE_OF.c
+++ b/skeletons/asn_SEQUENCE_OF.c
@@ -9,7 +9,7 @@
 
 void
 asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free) {
-	asn_sequence *as = asn_sequence_of_x;
+	asn_sequence *as = (asn_sequence *)asn_sequence_of_x;
 
 	if(as) {
 		void *ptr;
diff --git a/skeletons/asn_SET_OF.c b/skeletons/asn_SET_OF.c
index d89b357..c6afc30 100644
--- a/skeletons/asn_SET_OF.c
+++ b/skeletons/asn_SET_OF.c
@@ -13,7 +13,7 @@
  */
 int
 asn_set_add(void *asn_set_of_x, void *ptr) {
-	asn_set *as = asn_set_of_x;
+	asn_set *as = (asn_set *)asn_set_of_x;
 
 	if(as == 0 || ptr == 0) {
 		errno = EINVAL;		/* Invalid arguments */
@@ -28,7 +28,7 @@
 		void *_new_arr;
 		_new_arr = REALLOC(as->array, _newsize * sizeof(as->array[0]));
 		if(_new_arr) {
-			as->array = _new_arr;
+			as->array = (void **)_new_arr;
 			as->size = _newsize;
 		} else {
 			/* ENOMEM */
@@ -43,7 +43,7 @@
 
 void
 asn_set_del(void *asn_set_of_x, int number, int _do_free) {
-	asn_set *as = asn_set_of_x;
+	asn_set *as = (asn_set *)asn_set_of_x;
 
 	if(as) {
 		void *ptr;
@@ -71,7 +71,7 @@
  */
 void
 asn_set_empty(void *asn_set_of_x) {
-	asn_set *as = asn_set_of_x;
+	asn_set *as = (asn_set *)asn_set_of_x;
 
 	if(as) {
 		if(as->array) {
diff --git a/skeletons/ber_tlv_length.c b/skeletons/ber_tlv_length.c
index af87236..3ce5a6b 100644
--- a/skeletons/ber_tlv_length.c
+++ b/skeletons/ber_tlv_length.c
@@ -9,7 +9,7 @@
 ssize_t
 ber_fetch_length(int _is_constructed, void *bufptr, size_t size,
 		ber_tlv_len_t *len_r) {
-	uint8_t *buf = bufptr;
+	uint8_t *buf = (uint8_t *)bufptr;
 	unsigned oct;
 
 	if(size == 0)
@@ -119,7 +119,7 @@
 ssize_t
 der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size) {
 	size_t computed_size;	/* Size of len encoding */
-	uint8_t *buf = bufp;
+	uint8_t *buf = (uint8_t *)bufp;
 	uint8_t *end;
 	int i;
 
diff --git a/skeletons/ber_tlv_tag.c b/skeletons/ber_tlv_tag.c
index 26d7122..2664b90 100644
--- a/skeletons/ber_tlv_tag.c
+++ b/skeletons/ber_tlv_tag.c
@@ -102,7 +102,7 @@
 der_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) {
 	int tclass = BER_TAG_CLASS(tag);
 	ber_tlv_tag_t tval = BER_TAG_VALUE(tag);
-	uint8_t *buf = bufp;
+	uint8_t *buf = (uint8_t *)bufp;
 	uint8_t *end;
 	size_t computed_size;
 	int i;
diff --git a/skeletons/constr_CHOICE.c b/skeletons/constr_CHOICE.c
index a620b0c..7bcf5c5 100644
--- a/skeletons/constr_CHOICE.c
+++ b/skeletons/constr_CHOICE.c
@@ -66,8 +66,9 @@
  */
 static int
 _search4tag(const void *ap, const void *bp) {
-	const asn1_TYPE_tag2member_t *a = ap;
-	const asn1_TYPE_tag2member_t *b = bp;
+	const asn1_TYPE_tag2member_t *a = (const asn1_TYPE_tag2member_t *)ap;
+	const asn1_TYPE_tag2member_t *b = (const asn1_TYPE_tag2member_t *)bp;
+
 	int a_class = BER_TAG_CLASS(a->el_tag);
 	int b_class = BER_TAG_CLASS(b->el_tag);
 
@@ -97,7 +98,7 @@
 	/*
 	 * Bring closer parts of structure description.
 	 */
-	asn1_CHOICE_specifics_t *specs = sd->specifics;
+	asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)sd->specifics;
 	asn1_CHOICE_element_t *elements = specs->elements;
 
 	/*
@@ -183,7 +184,8 @@
 			asn1_TYPE_tag2member_t key;
 
 			key.el_tag = tlv_tag;
-			t2m = bsearch(&key, specs->tag2el, specs->tag2el_count,
+			(void *)t2m = bsearch(&key,
+					specs->tag2el, specs->tag2el_count,
 					sizeof(specs->tag2el[0]), _search4tag);
 			if(t2m) {
 				/*
@@ -227,7 +229,7 @@
 	    do {
 		asn1_CHOICE_element_t *elm;	/* CHOICE's element */
 		void *memb_ptr;		/* Pointer to the member */
-		void *memb_ptr2;	/* Pointer to that pointer */
+		void **memb_ptr2;	/* Pointer to that pointer */
 
 		elm = &elements[ctx->step];
 
@@ -238,7 +240,7 @@
 		 */
 		if(elm->optional) {
 			/* Optional member, hereby, a simple pointer */
-			memb_ptr2 = (char *)st + elm->memb_offset;
+			memb_ptr2 = (void **)((char *)st + elm->memb_offset);
 		} else {
 			/*
 			 * A pointer to a pointer
@@ -250,8 +252,7 @@
 		/*
 		 * Invoke the member fetch routine according to member's type
 		 */
-		rval = elm->type->ber_decoder(
-				(void *)elm->type,
+		rval = elm->type->ber_decoder(elm->type,
 				memb_ptr2, ptr, LEFT,
 				elm->tag_mode);
 		switch(rval.code) {
@@ -352,7 +353,7 @@
 		void *struct_ptr,
 		int tag_mode, ber_tlv_tag_t tag,
 		asn_app_consume_bytes_f *cb, void *app_key) {
-	asn1_CHOICE_specifics_t *specs = sd->specifics;
+	asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)sd->specifics;
 	asn1_CHOICE_element_t *elm;	/* CHOICE element */
 	der_enc_rval_t erval;
 	void *memb_ptr;
@@ -442,7 +443,7 @@
 
 ber_tlv_tag_t
 CHOICE_outmost_tag(asn1_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber_tlv_tag_t tag) {
-	asn1_CHOICE_specifics_t *specs = td->specifics;
+	asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)td->specifics;
 	int present;
 
 	assert(tag_mode == 0);
@@ -475,7 +476,7 @@
 int
 CHOICE_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
-	asn1_CHOICE_specifics_t *specs = td->specifics;
+	asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)td->specifics;
 	int present;
 
 	if(!sptr) {
@@ -509,7 +510,7 @@
 int
 CHOICE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 		asn_app_consume_bytes_f *cb, void *app_key) {
-	asn1_CHOICE_specifics_t *specs = td->specifics;
+	asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)td->specifics;
 	int present;
 
 	if(!sptr) return cb("<absent>", 8, app_key);
@@ -547,7 +548,7 @@
 
 void
 CHOICE_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
-	asn1_CHOICE_specifics_t *specs = td->specifics;
+	asn1_CHOICE_specifics_t *specs = (asn1_CHOICE_specifics_t *)td->specifics;
 	int present;
 
 	if(!td || !ptr)
diff --git a/skeletons/constr_SEQUENCE.c b/skeletons/constr_SEQUENCE.c
index f273681..db36f90 100644
--- a/skeletons/constr_SEQUENCE.c
+++ b/skeletons/constr_SEQUENCE.c
@@ -69,8 +69,9 @@
  */
 static int
 _t2e_cmp(const void *ap, const void *bp) {
-	const asn1_TYPE_tag2member_t *a = ap;
-	const asn1_TYPE_tag2member_t *b = bp;
+	const asn1_TYPE_tag2member_t *a = (const asn1_TYPE_tag2member_t *)ap;
+	const asn1_TYPE_tag2member_t *b = (const asn1_TYPE_tag2member_t *)bp;
+
 	int a_class = BER_TAG_CLASS(a->el_tag);
 	int b_class = BER_TAG_CLASS(b->el_tag);
 
@@ -107,7 +108,7 @@
 	/*
 	 * Bring closer parts of structure description.
 	 */
-	asn1_SEQUENCE_specifics_t *specs = sd->specifics;
+	asn1_SEQUENCE_specifics_t *specs = (asn1_SEQUENCE_specifics_t *)sd->specifics;
 	asn1_SEQUENCE_element_t *elements = specs->elements;
 
 	/*
@@ -184,7 +185,7 @@
 	  for(edx = (ctx->step >> 1); edx < specs->elements_count;
 			edx++, ctx->step = (ctx->step & ~1) + 2) {
 		void *memb_ptr;		/* Pointer to the member */
-		void *memb_ptr2;	/* Pointer to that pointer */
+		void **memb_ptr2;	/* Pointer to that pointer */
 		ssize_t tag_len;	/* Length of TLV's T */
 		int opt_edx_end;	/* Next non-optional element */
 		int use_bsearch;
@@ -267,7 +268,8 @@
 			asn1_TYPE_tag2member_t key;
 			key.el_tag = tlv_tag;
 			key.el_no = edx;
-			t2m = bsearch(&key, specs->tag2el, specs->tag2el_count,
+			(void *)t2m = bsearch(&key,
+				specs->tag2el, specs->tag2el_count,
 				sizeof(specs->tag2el[0]), _t2e_cmp);
 			if(t2m) {
 				asn1_TYPE_tag2member_t *best = 0;
@@ -366,7 +368,7 @@
 		 */
 		if(elements[edx].optional) {
 			/* Optional member, hereby, a simple pointer */
-			memb_ptr2 = (char *)st + elements[edx].memb_offset;
+			memb_ptr2 = (void **)((char *)st + elements[edx].memb_offset);
 		} else {
 			/*
 			 * A pointer to a pointer
@@ -379,7 +381,7 @@
 		 * Invoke the member fetch routine according to member's type
 		 */
 		rval = elements[edx].type->ber_decoder(
-				(void *)elements[edx].type,
+				elements[edx].type,
 				memb_ptr2, ptr, LEFT,
 				elements[edx].tag_mode);
 		ASN_DEBUG("In %s SEQUENCE decoded %d %s in %d bytes code %d",
@@ -479,7 +481,7 @@
 SEQUENCE_encode_der(asn1_TYPE_descriptor_t *sd,
 	void *ptr, int tag_mode, ber_tlv_tag_t tag,
 	asn_app_consume_bytes_f *cb, void *app_key) {
-	asn1_SEQUENCE_specifics_t *specs = sd->specifics;
+	asn1_SEQUENCE_specifics_t *specs = (asn1_SEQUENCE_specifics_t *)sd->specifics;
 	size_t computed_size = 0;
 	der_enc_rval_t erval;
 	ssize_t ret;
@@ -564,7 +566,7 @@
 int
 SEQUENCE_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 		asn_app_consume_bytes_f *cb, void *app_key) {
-	asn1_SEQUENCE_specifics_t *specs = td->specifics;
+	asn1_SEQUENCE_specifics_t *specs = (asn1_SEQUENCE_specifics_t *)td->specifics;
 	int edx;
 	int ret;
 
@@ -612,7 +614,7 @@
 
 void
 SEQUENCE_free(asn1_TYPE_descriptor_t *td, void *sptr, int contents_only) {
-	asn1_SEQUENCE_specifics_t *specs = td->specifics;
+	asn1_SEQUENCE_specifics_t *specs = (asn1_SEQUENCE_specifics_t *)td->specifics;
 	int edx;
 
 	if(!td || !sptr)
@@ -641,7 +643,7 @@
 int
 SEQUENCE_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
-	asn1_SEQUENCE_specifics_t *specs = td->specifics;
+	asn1_SEQUENCE_specifics_t *specs = (asn1_SEQUENCE_specifics_t *)td->specifics;
 	int edx;
 
 	if(!sptr) {
diff --git a/skeletons/constr_SEQUENCE_OF.c b/skeletons/constr_SEQUENCE_OF.c
index a839949..0370a2d 100644
--- a/skeletons/constr_SEQUENCE_OF.c
+++ b/skeletons/constr_SEQUENCE_OF.c
@@ -12,9 +12,9 @@
 SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
 	int tag_mode, ber_tlv_tag_t tag,
 	asn_app_consume_bytes_f *cb, void *app_key) {
-	asn1_SET_OF_specifics_t *specs = sd->specifics;
+	asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)sd->specifics;
 	asn1_SET_OF_element_t *elm = specs->element;
-	A_SEQUENCE_OF(void) *list = ptr;
+	A_SEQUENCE_OF(void) *list;
 	size_t computed_size = 0;
 	ssize_t encoding_size = 0;
 	der_enc_rval_t erval;
@@ -25,6 +25,7 @@
 	/*
 	 * Gather the length of the underlying members sequence.
 	 */
+	(void *)list = ptr;
 	for(edx = 0; edx < list->count; edx++) {
 		void *memb_ptr = list->array[edx];
 		erval = elm->type->der_encoder(elm->type, memb_ptr,
diff --git a/skeletons/constr_SET.c b/skeletons/constr_SET.c
index 2477a38..ec9caf0 100644
--- a/skeletons/constr_SET.c
+++ b/skeletons/constr_SET.c
@@ -66,8 +66,9 @@
  */
 static int
 _t2e_cmp(const void *ap, const void *bp) {
-	const asn1_TYPE_tag2member_t *a = ap;
-	const asn1_TYPE_tag2member_t *b = bp;
+	const asn1_TYPE_tag2member_t *a = (const asn1_TYPE_tag2member_t *)ap;
+	const asn1_TYPE_tag2member_t *b = (const asn1_TYPE_tag2member_t *)bp;
+
 	int a_class = BER_TAG_CLASS(a->el_tag);
 	int b_class = BER_TAG_CLASS(b->el_tag);
 
@@ -97,7 +98,7 @@
 	/*
 	 * Bring closer parts of structure description.
 	 */
-	asn1_SET_specifics_t *specs = sd->specifics;
+	asn1_SET_specifics_t *specs = (asn1_SET_specifics_t *)sd->specifics;
 	asn1_SET_element_t *elements = specs->elements;
 
 	/*
@@ -179,7 +180,7 @@
 			ctx->step = (ctx->step & ~1) + 2,
 				edx = (ctx->step >> 1)) {
 		void *memb_ptr;		/* Pointer to the member */
-		void *memb_ptr2;	/* Pointer to that pointer */
+		void **memb_ptr2;	/* Pointer to that pointer */
 		ssize_t tag_len;	/* Length of TLV's T */
 
 		if(ctx->step & 1)
@@ -234,7 +235,8 @@
 			asn1_TYPE_tag2member_t key;
 
 			key.el_tag = tlv_tag;
-			t2m = bsearch(&key, specs->tag2el, specs->tag2el_count,
+			(void *)t2m = bsearch(&key,
+					specs->tag2el, specs->tag2el_count,
 					sizeof(specs->tag2el[0]), _t2e_cmp);
 			if(t2m) {
 				/*
@@ -294,7 +296,7 @@
 		 */
 		if(elements[edx].optional) {
 			/* Optional member, hereby, a simple pointer */
-			memb_ptr2 = (char *)st + elements[edx].memb_offset;
+			memb_ptr2 = (void **)((char *)st + elements[edx].memb_offset);
 		} else {
 			/*
 			 * A pointer to a pointer
@@ -307,7 +309,7 @@
 		 * Invoke the member fetch routine according to member's type
 		 */
 		rval = elements[edx].type->ber_decoder(
-				(void *)elements[edx].type,
+				elements[edx].type,
 				memb_ptr2, ptr, LEFT,
 				elements[edx].tag_mode);
 		switch(rval.code) {
@@ -432,7 +434,7 @@
 SET_encode_der(asn1_TYPE_descriptor_t *sd,
 	void *ptr, int tag_mode, ber_tlv_tag_t tag,
 	asn_app_consume_bytes_f *cb, void *app_key) {
-	asn1_SET_specifics_t *specs = sd->specifics;
+	asn1_SET_specifics_t *specs = (asn1_SET_specifics_t *)sd->specifics;
 	size_t computed_size = 0;
 	der_enc_rval_t my_erval;
 	int t2m_build_own = (specs->tag2el_count != specs->elements_count);
@@ -445,14 +447,14 @@
 	 * Use existing, or build our own tags map.
 	 */
 	if(t2m_build_own) {
-		t2m = alloca(specs->elements_count * sizeof(t2m[0]));
-		t2m_count = 0;
+		(void *)t2m = alloca(specs->elements_count * sizeof(t2m[0]));
 		if(!t2m) {	/* There are such platforms */
 			my_erval.encoded = -1;
 			my_erval.failed_type = sd;
 			my_erval.structure_ptr = ptr;
 			return my_erval;
 		}
+		t2m_count = 0;
 	} else {
 		/*
 		 * There is no untagged CHOICE in this SET.
@@ -578,7 +580,7 @@
 int
 SET_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 		asn_app_consume_bytes_f *cb, void *app_key) {
-	asn1_SET_specifics_t *specs = td->specifics;
+	asn1_SET_specifics_t *specs = (asn1_SET_specifics_t *)td->specifics;
 	int edx;
 	int ret;
 
@@ -625,7 +627,7 @@
 
 void
 SET_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
-	asn1_SET_specifics_t *specs = td->specifics;
+	asn1_SET_specifics_t *specs = (asn1_SET_specifics_t *)td->specifics;
 	int edx;
 
 	if(!td || !ptr)
@@ -654,7 +656,7 @@
 int
 SET_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
-	asn1_SET_specifics_t *specs = td->specifics;
+	asn1_SET_specifics_t *specs = (asn1_SET_specifics_t *)td->specifics;
 	int edx;
 
 	if(!sptr) {
diff --git a/skeletons/constr_SET_OF.c b/skeletons/constr_SET_OF.c
index 84fb895..3bebf7d 100644
--- a/skeletons/constr_SET_OF.c
+++ b/skeletons/constr_SET_OF.c
@@ -65,7 +65,7 @@
 	/*
 	 * Bring closer parts of structure description.
 	 */
-	asn1_SET_OF_specifics_t *specs = sd->specifics;
+	asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)sd->specifics;
 	asn1_SET_OF_element_t *element = specs->element;
 
 	/*
@@ -201,8 +201,7 @@
 		/*
 		 * Invoke the member fetch routine according to member's type
 		 */
-		rval = element->type->ber_decoder(
-				(void *)element->type,
+		rval = element->type->ber_decoder(element->type,
 				&ctx->ptr, ptr, LEFT, 0);
 		ASN_DEBUG("In %s SET OF %s code %d consumed %d",
 			sd->name, element->type->name,
@@ -210,7 +209,8 @@
 		switch(rval.code) {
 		case RC_OK:
 			{
-				A_SET_OF(void) *list = st;
+				A_SET_OF(void) *list;
+				(void *)list = st;
 				if(ASN_SET_ADD(list, ctx->ptr) != 0)
 					RETURN(RC_FAIL);
 				else
@@ -269,7 +269,7 @@
 };
 /* Append bytes to the above structure */
 static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) {
-	struct _el_buffer *el_buf = el_buf_ptr;
+	struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr;
 
 	if(el_buf->length + size > el_buf->size)
 		return -1;
@@ -280,8 +280,8 @@
 	return 0;
 }
 static int _el_buf_cmp(const void *ap, const void *bp) {
-	const struct _el_buffer *a = ap;
-	const struct _el_buffer *b = bp;
+	const struct _el_buffer *a = (const struct _el_buffer *)ap;
+	const struct _el_buffer *b = (const struct _el_buffer *)bp;
 	int ret;
 	size_t common_len;
 
@@ -308,11 +308,11 @@
 SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
 	int tag_mode, ber_tlv_tag_t tag,
 	asn_app_consume_bytes_f *cb, void *app_key) {
-	asn1_SET_OF_specifics_t *specs = sd->specifics;
+	asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)sd->specifics;
 	asn1_SET_OF_element_t *elm = specs->element;
 	asn1_TYPE_descriptor_t *elm_type = elm->type;
 	der_type_encoder_f *der_encoder = elm_type->der_encoder;
-	A_SET_OF(void) *list = ptr;
+	A_SET_OF(void) *list;
 	size_t computed_size = 0;
 	ssize_t encoding_size = 0;
 	struct _el_buffer *encoded_els;
@@ -326,6 +326,7 @@
 	/*
 	 * Gather the length of the underlying members sequence.
 	 */
+	(void *)list = ptr;
 	for(edx = 0; edx < list->count; edx++) {
 		void *memb_ptr = list->array[edx];
 		erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0);
@@ -361,7 +362,7 @@
 	 * according to their encodings. Build an array of the
 	 * encoded elements.
 	 */
-	encoded_els = MALLOC(list->count * sizeof(encoded_els[0]));
+	(void *)encoded_els = MALLOC(list->count * sizeof(encoded_els[0]));
 	if(encoded_els == NULL) {
 		erval.encoded = -1;
 		erval.failed_type = sd;
@@ -381,7 +382,7 @@
 		/*
 		 * Prepare space for encoding.
 		 */
-		encoded_el->buf = MALLOC(max_encoded_len);
+		encoded_el->buf = (uint8_t *)MALLOC(max_encoded_len);
 		if(encoded_el->buf) {
 			encoded_el->length = 0;
 			encoded_el->size = max_encoded_len;
@@ -447,9 +448,9 @@
 int
 SET_OF_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
 		asn_app_consume_bytes_f *cb, void *app_key) {
-	asn1_SET_OF_specifics_t *specs = td->specifics;
+	asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)td->specifics;
 	asn1_SET_OF_element_t *element = specs->element;
-	const A_SET_OF(void) *list = sptr;
+	const A_SET_OF(void) *list;
 	int ret;
 	int i;
 
@@ -460,6 +461,7 @@
 	|| cb(" ::= {\n", 7, app_key))
 		return -1;
 
+	(void *)list = sptr;
 	for(i = 0; i < list->count; i++) {
 		const void *memb_ptr = list->array[i];
 		if(!memb_ptr) continue;
@@ -484,15 +486,16 @@
 void
 SET_OF_free(asn1_TYPE_descriptor_t *td, void *ptr, int contents_only) {
 	if(td && ptr) {
-		asn1_SET_OF_specifics_t *specs = td->specifics;
+		asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)td->specifics;
 		asn1_SET_OF_element_t *element = specs->element;
-		A_SET_OF(void) *list = ptr;
+		A_SET_OF(void) *list;
 		int i;
 
 		/*
 		 * Could not use set_of_empty() because of (*free)
 		 * incompatibility.
 		 */
+		(void *)list = ptr;
 		for(i = 0; i < list->count; i++) {
 			void *memb_ptr = list->array[i];
 			if(memb_ptr)
@@ -511,9 +514,9 @@
 int
 SET_OF_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
 		asn_app_consume_bytes_f *app_errlog, void *app_key) {
-	asn1_SET_OF_specifics_t *specs = td->specifics;
+	asn1_SET_OF_specifics_t *specs = (asn1_SET_OF_specifics_t *)td->specifics;
 	asn1_SET_OF_element_t *element = specs->element;
-	const A_SET_OF(void) *list = sptr;
+	const A_SET_OF(void) *list;
 	int i;
 
 	if(!sptr) {
@@ -521,6 +524,8 @@
 		return -1;
 	}
 
+	(void *)list = sptr;
+
 	for(i = 0; i < list->count; i++) {
 		const void *memb_ptr = list->array[i];
 		if(!memb_ptr) continue;
diff --git a/skeletons/constr_TYPE.c b/skeletons/constr_TYPE.c
index 2a19bc9..e19f8d9 100644
--- a/skeletons/constr_TYPE.c
+++ b/skeletons/constr_TYPE.c
@@ -48,7 +48,7 @@
 /* Dump the data into the specified stdio stream */
 static int
 _print2fp(const void *buffer, size_t size, void *app_key) {
-	FILE *stream = app_key;
+	FILE *stream = (FILE *)app_key;
 
 	if(fwrite(buffer, 1, size, stream) != size)
 		return -1;
diff --git a/skeletons/constraints.c b/skeletons/constraints.c
index 5f01cc7..a7dce95 100644
--- a/skeletons/constraints.c
+++ b/skeletons/constraints.c
@@ -35,7 +35,7 @@
 
 static int
 __fill_errbuf(const void *buffer, size_t size, void *app_key) {
-	struct __fill_errbuf_arg *arg = app_key;
+	struct __fill_errbuf_arg *arg = (struct __fill_errbuf_arg *)app_key;
 	size_t avail = arg->errlen - arg->erroff;
 
 	if(avail > size)
@@ -107,7 +107,7 @@
 	 * More space required to hold the message.
 	 */
 	len = ret + 1;
-	p = alloca(len);
+	p = (char *)alloca(len);
 	if(!p) return;	/* Can fail on !x86. */
 
 	
diff --git a/skeletons/der_encoder.c b/skeletons/der_encoder.c
index 9ed91ce..ddd0bf8 100644
--- a/skeletons/der_encoder.c
+++ b/skeletons/der_encoder.c
@@ -60,7 +60,7 @@
 		 * and initialize it appropriately.
 		 */
 		int stag_offset;
-		tags = alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t));
+		tags = (ber_tlv_tag_t *)alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t));
 		if(!tags) {	/* Can fail on !x86 */
 			errno = ENOMEM;
 			return -1;
@@ -82,7 +82,7 @@
 	if(tags_count == 0)
 		return 0;
 
-	lens = alloca(tags_count * sizeof(lens[0]));
+	lens = (ssize_t *)alloca(tags_count * sizeof(lens[0]));
 	if(!lens) {
 		errno = ENOMEM;
 		return -1;