stop ignoring formatting problems, start ignoring long long extension problems
diff --git a/configure.ac b/configure.ac
index 6a0f062..837718c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,6 +114,9 @@
         [SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -Wgnu"])
   ])
 
+AX_CHECK_COMPILE_FLAG([-Wno-long-long],
+        [SKELETONS_CFLAGS="${SKELETONS_CFLAGS} -Wno-long-long"])
+
 AC_ARG_ENABLE(test-Werror,
   [AS_HELP_STRING([--enable-test-Werror],
                   [abort compiling tests after any C compiler warning])],
@@ -121,9 +124,6 @@
   AS_IF([test x$enable_test_werror != xno], [
       TESTSUITE_CFLAGS="${TESTSUITE_CFLAGS} -Werror -W -Wpointer-arith"
   ])
-AX_CHECK_COMPILE_FLAG([-Wno-format],
-    [SKELETONS_CFLAGS="$SKELETONS_CFLAGS -Wno-format"])
-
 
 dnl If requested and -m32 is available to create 32-bit code,
 dnl treat it like a special case to be checked.
diff --git a/skeletons/ANY.c b/skeletons/ANY.c
index b370f53..6bd5e67 100644
--- a/skeletons/ANY.c
+++ b/skeletons/ANY.c
@@ -220,7 +220,7 @@
         if(raw_len < 0) RETURN(RC_WMORE);
         if(raw_len == 0 && st->buf) break;
 
-        ASN_DEBUG("Got PER length len %zu, %s (%s)", raw_len,
+        ASN_DEBUG("Got PER length len %" ASN_PRI_SIZE ", %s (%s)", raw_len,
                   repeat ? "repeat" : "once", td->name);
         len_bytes = raw_len;
         len_bits = len_bytes * 8;
diff --git a/skeletons/BIT_STRING.c b/skeletons/BIT_STRING.c
index 8592f65..0cff770 100644
--- a/skeletons/BIT_STRING.c
+++ b/skeletons/BIT_STRING.c
@@ -459,7 +459,7 @@
     size_in_bits = 8 * st->size - st->bits_unused;
 
     ASN_DEBUG(
-        "Encoding %s into %zu bits"
+        "Encoding %s into %" ASN_PRI_SIZE " bits"
         " (%ld..%ld, effective %d)%s",
         td->name, size_in_bits, csiz->lower_bound, csiz->upper_bound,
         csiz->effective_bits, ct_extensible ? " EXT" : "");
@@ -488,8 +488,8 @@
     if(csiz->effective_bits >= 0 && !inext) {
         int add_trailer = (ssize_t)size_in_bits < csiz->lower_bound;
         ASN_DEBUG(
-            "Encoding %zu bytes (%ld), length (in %d bits) trailer %d; actual "
-            "value %zd",
+            "Encoding %" ASN_PRI_SIZE " bytes (%ld), length (in %d bits) trailer %d; actual "
+            "value %" ASN_PRI_SSIZE "",
             st->size, size_in_bits - csiz->lower_bound, csiz->effective_bits,
             add_trailer,
             add_trailer ? 0 : (ssize_t)size_in_bits - csiz->lower_bound);
@@ -516,7 +516,7 @@
         ASN__ENCODED_OK(er);
     }
 
-    ASN_DEBUG("Encoding %zu bytes", st->size);
+    ASN_DEBUG("Encoding %" ASN_PRI_SIZE " bytes", st->size);
 
     buf = st->buf;
     do {
@@ -524,7 +524,7 @@
         ssize_t maySave = uper_put_length(po, size_in_bits, &need_eom);
         if(maySave < 0) ASN__ENCODE_FAILED;
 
-        ASN_DEBUG("Encoding %zd of %zu", maySave, size_in_bits);
+        ASN_DEBUG("Encoding %" ASN_PRI_SSIZE " of %" ASN_PRI_SIZE "", maySave, size_in_bits);
 
         ret = per_put_many_bits(po, buf, maySave);
         if(ret) ASN__ENCODE_FAILED;
diff --git a/skeletons/BIT_STRING_oer.c b/skeletons/BIT_STRING_oer.c
index a5f289c..aff5075 100644
--- a/skeletons/BIT_STRING_oer.c
+++ b/skeletons/BIT_STRING_oer.c
@@ -118,7 +118,7 @@
     if(ct_size >= 0) {
         size_t ct_bytes = (ct_size + 7) >> 3;
         if(st->size > ct_bytes) {
-            ASN_DEBUG("More bits in BIT STRING %s (%zd) than constrained %zd",
+            ASN_DEBUG("More bits in BIT STRING %s (%" ASN_PRI_SSIZE ") than constrained %" ASN_PRI_SSIZE "",
                       td->name, 8 * st->size - st->bits_unused, ct_size);
             ASN__ENCODE_FAILED;
         }
diff --git a/skeletons/BMPString.c b/skeletons/BMPString.c
index e9958ff..86223fe 100644
--- a/skeletons/BMPString.c
+++ b/skeletons/BMPString.c
@@ -71,7 +71,7 @@
     if(st && st->buf) {
         if(st->size & 1) {
             ASN__CTFAIL(app_key, td, sptr,
-                        "%s: invalid size %zu not divisible by 2 (%s:%d)",
+                        "%s: invalid size %" ASN_PRI_SIZE " not divisible by 2 (%s:%d)",
                         td->name, st->size, __FILE__, __LINE__);
             return -1;
         }
diff --git a/skeletons/INTEGER.c b/skeletons/INTEGER.c
index 6a914ea..73da665 100644
--- a/skeletons/INTEGER.c
+++ b/skeletons/INTEGER.c
@@ -149,7 +149,7 @@
 		if(el) {
 			if(plainOrXER == 0)
 				return asn__format_to_callback(cb, app_key,
-					"%" PRIdMAX " (%s)", value, el->enum_name);
+					"%" ASN_PRIdMAX " (%s)", value, el->enum_name);
 			else
 				return asn__format_to_callback(cb, app_key,
 					"<%s/>", el->enum_name);
@@ -160,8 +160,10 @@
 			return -1;
 		} else {
             return asn__format_to_callback(cb, app_key,
-                (specs && specs->field_unsigned) ? "%" PRIuMAX : "%" PRIdMAX,
-                value);
+                                           (specs && specs->field_unsigned)
+                                               ? "%" ASN_PRIuMAX
+                                               : "%" ASN_PRIdMAX,
+                                           value);
         }
 	} else if(plainOrXER && specs && specs->strict_enumeration) {
 		/*
@@ -729,7 +731,7 @@
 				|| uval > (unsigned long)ct->upper_bound)
 					inext = 1;
 			}
-			ASN_DEBUG("Value %lu (%02x/%zu) lb %lu ub %lu %s",
+			ASN_DEBUG("Value %lu (%02x/%" ASN_PRI_SIZE ") lb %lu ub %lu %s",
 				uval, st->buf[0], st->size,
 				ct->lower_bound, ct->upper_bound,
 				inext ? "ext" : "fix");
@@ -746,7 +748,7 @@
 				|| value > ct->upper_bound)
 					inext = 1;
 			}
-			ASN_DEBUG("Value %ld (%02x/%zu) lb %ld ub %ld %s",
+			ASN_DEBUG("Value %ld (%02x/%" ASN_PRI_SIZE ") lb %ld ub %ld %s",
 				value, st->buf[0], st->size,
 				ct->lower_bound, ct->upper_bound,
 				inext ? "ext" : "fix");
diff --git a/skeletons/Makefile.am b/skeletons/Makefile.am
index 698e4bb..3b55d7b 100644
--- a/skeletons/Makefile.am
+++ b/skeletons/Makefile.am
@@ -1,6 +1,5 @@
 
 CFLAGS = $(filter-out $(CODE_COVERAGE_CFLAGS), @CFLAGS@)
-CFLAGS += ${SKELETONS_CFLAGS}   # Put -std=c89 at the end!
 
 dist_pkgdata_DATA =				\
 		${srcdir}/README		\
@@ -19,13 +18,20 @@
 	-@echo -n " "
 	-rm -f -r $(DESTDIR)$(pkgdatadir)
 
-check_LTLIBRARIES = libasn1cskeletons.la libasn1cskeletons_32.la
+check_LTLIBRARIES =             \
+    libasn1cskeletons.la        \
+    libasn1cskeletons_c89.la    \
+    libasn1cskeletons_c89_32.la
+
+libasn1cskeletons_c89_la_CFLAGS = $(SKELETONS_CFLAGS)
+libasn1cskeletons_c89_la_SOURCES = $(libasn1cskeletons_la_SOURCES)
 
 if EXPLICIT_M32
-libasn1cskeletons_32_la_CFLAGS = $(CFLAGS_M32)
-libasn1cskeletons_32_la_SOURCES = $(libasn1cskeletons_la_SOURCES)
+libasn1cskeletons_c89_32_la_CFLAGS = $(SKELETONS_CFLAGS) $(CFLAGS_M32) -Wno-format
+libasn1cskeletons_c89_32_la_SOURCES = $(libasn1cskeletons_la_SOURCES)
 endif
 
+libasn1cskeletons_la_CFLAGS = $(TESTSUITE_CFLAGS)
 libasn1cskeletons_la_SOURCES =                  \
     ANY.c ANY.h                                 \
     BIT_STRING.c BIT_STRING.h                   \
@@ -95,9 +101,21 @@
     xer_encoder.c xer_encoder.h                 \
     xer_support.c xer_support.h
 
-check_PROGRAMS = check-converter_example
+check_PROGRAMS =                    \
+    check-converter_example         \
+    check-converter_c89_example     \
+    check-converter_c89_32_example
 LDADD = -lm
 
 check_converter_example_CFLAGS = -DNO_ASN_PDU
 check_converter_example_SOURCES = converter-example.c
 check_converter_example_LDADD = libasn1cskeletons.la
+
+check_converter_c89_example_CFLAGS = $(SKELETON_CFLAGS) -DNO_ASN_PDU
+check_converter_c89_example_SOURCES = converter-example.c
+check_converter_c89_example_LDADD = libasn1cskeletons_c89.la
+
+check_converter_c89_32_example_CFLAGS = $(SKELETON_CFLAGS) $(CFLAGS_M32) -DNO_ASN_PDU
+check_converter_c89_32_example_SOURCES = converter-example.c
+check_converter_c89_32_example_LDADD = libasn1cskeletons_c89_32.la
+
diff --git a/skeletons/NativeReal.c b/skeletons/NativeReal.c
index 448e1b1..b1d1a7e 100644
--- a/skeletons/NativeReal.c
+++ b/skeletons/NativeReal.c
@@ -473,7 +473,7 @@
         ret = asn_REAL2double(&tmp, &d);
         if(tmp.buf != scratch) FREEMEM(tmp.buf);
         if(ret) {
-            ASN_DEBUG("REAL decoded in %zu bytes, but can't convert t double",
+            ASN_DEBUG("REAL decoded in %" ASN_PRI_SIZE " bytes, but can't convert t double",
                       real_body_len);
             ASN__DECODE_FAILED;
         }
diff --git a/skeletons/OCTET_STRING.c b/skeletons/OCTET_STRING.c
index c16e899..a692851 100644
--- a/skeletons/OCTET_STRING.c
+++ b/skeletons/OCTET_STRING.c
@@ -1574,7 +1574,7 @@
 		break;
 	}
 
-	ASN_DEBUG("Encoding %s into %zu units of %d bits"
+	ASN_DEBUG("Encoding %s into %" ASN_PRI_SIZE " units of %d bits"
 		" (%ld..%ld, effective %d)%s",
 		td->name, size_in_units, unit_bits,
 		csiz->lower_bound, csiz->upper_bound,
@@ -1604,7 +1604,7 @@
 	}
 
     if(csiz->effective_bits >= 0 && !inext) {
-        ASN_DEBUG("Encoding %zu bytes (%ld), length in %d bits", st->size,
+        ASN_DEBUG("Encoding %" ASN_PRI_SIZE " bytes (%ld), length in %d bits", st->size,
                   size_in_units - csiz->lower_bound, csiz->effective_bits);
         ret = per_put_few_bits(po, size_in_units - csiz->lower_bound,
                                csiz->effective_bits);
@@ -1616,16 +1616,16 @@
         ASN__ENCODED_OK(er);
     }
 
-    ASN_DEBUG("Encoding %zu bytes", st->size);
+    ASN_DEBUG("Encoding %" ASN_PRI_SIZE " bytes", st->size);
 
     buf = st->buf;
-    ASN_DEBUG("Encoding %zu in units", size_in_units);
+    ASN_DEBUG("Encoding %" ASN_PRI_SIZE " in units", size_in_units);
     do {
         int need_eom = 0;
         ssize_t may_save = uper_put_length(po, size_in_units, &need_eom);
         if(may_save < 0) ASN__ENCODE_FAILED;
 
-        ASN_DEBUG("Encoding %zd of %zu%s", may_save, size_in_units,
+        ASN_DEBUG("Encoding %" ASN_PRI_SSIZE " of %" ASN_PRI_SIZE "%s", may_save, size_in_units,
                   need_eom ? ",+EOM" : "");
 
         ret = OCTET_STRING_per_put_characters(po, buf, may_save, bpc, unit_bits,
diff --git a/skeletons/OCTET_STRING_oer.c b/skeletons/OCTET_STRING_oer.c
index c2f9a5c..c16faea 100644
--- a/skeletons/OCTET_STRING_oer.c
+++ b/skeletons/OCTET_STRING_oer.c
@@ -71,7 +71,7 @@
 
         if(expected_length % unit_bytes != 0) {
             ASN_DEBUG(
-                "Data size %zu bytes is not consistent with multiplier %zu",
+                "Data size %" ASN_PRI_SIZE " bytes is not consistent with multiplier %" ASN_PRI_SIZE "",
                 expected_length, unit_bytes);
             ASN__DECODE_FAILED;
         }
@@ -115,7 +115,7 @@
 
     if(!st) ASN__ENCODE_FAILED;
 
-    ASN_DEBUG("Encoding %s %zu as OCTET STRING", td ? td->name : "", st->size);
+    ASN_DEBUG("Encoding %s %" ASN_PRI_SIZE " as OCTET STRING", td ? td->name : "", st->size);
 
     if(ct_size >= 0) {
         /*
@@ -142,8 +142,8 @@
 
         if(st->size != unit_bytes * (size_t)ct_size) {
             ASN_DEBUG(
-                "Trying to encode %s (%zu bytes) which doesn't fit SIZE "
-                "constraint (%zu)",
+                "Trying to encode %s (%" ASN_PRI_SIZE " bytes) which doesn't fit SIZE "
+                "constraint (%" ASN_PRI_SIZE ")",
                 td->name, st->size, ct_size);
             ASN__ENCODE_FAILED;
         }
diff --git a/skeletons/UniversalString.c b/skeletons/UniversalString.c
index e4a08d5..da28874 100644
--- a/skeletons/UniversalString.c
+++ b/skeletons/UniversalString.c
@@ -72,7 +72,7 @@
     if(st && st->buf) {
         if(st->size % 4) {
             ASN__CTFAIL(app_key, td, sptr,
-                        "%s: invalid size %zu not divisible by 4 (%s:%d)",
+                        "%s: invalid size %" ASN_PRI_SIZE " not divisible by 4 (%s:%d)",
                         td->name, st->size, __FILE__, __LINE__);
             return -1;
         }
diff --git a/skeletons/asn_application.c b/skeletons/asn_application.c
index 5b25207..e96acc9 100644
--- a/skeletons/asn_application.c
+++ b/skeletons/asn_application.c
@@ -134,7 +134,7 @@
                              overrun_encoder_cb, &buf_key);
 
     if(er.encoded >= 0 && (size_t)er.encoded != buf_key.computed_size) {
-        ASN_DEBUG("asn_encode() returned %zd yet produced %zu bytes",
+        ASN_DEBUG("asn_encode() returned %" ASN_PRI_SSIZE " yet produced %" ASN_PRI_SIZE " bytes",
                   er.encoded, buf_key.computed_size);
         assert(er.encoded < 0 || (size_t)er.encoded == buf_key.computed_size);
     }
diff --git a/skeletons/asn_bit_data.c b/skeletons/asn_bit_data.c
index 056e8f3..fe4b89b 100644
--- a/skeletons/asn_bit_data.c
+++ b/skeletons/asn_bit_data.c
@@ -38,13 +38,12 @@
 	static char buf[2][32];
 	static int n;
 	n = (n+1) % 2;
-	snprintf(buf[n], sizeof(buf[n]),
-		"{m=%ld span %+ld[%d..%d] (%d)}",
-		(long)pd->moved,
-		(((long)pd->buffer) & 0xf),
-		(int)pd->nboff, (int)pd->nbits,
-		(int)(pd->nbits - pd->nboff));
-	return buf[n];
+    snprintf(buf[n], sizeof(buf[n]),
+             "{m=%" ASN_PRI_SIZE " span %" ASN_PRI_SIZE "[%" ASN_PRI_SIZE
+             "..%" ASN_PRI_SIZE "] (%" ASN_PRI_SIZE ")}",
+             pd->moved, ((uintptr_t)(pd->buffer) & 0xf), pd->nboff, pd->nbits,
+             pd->nbits - pd->nboff);
+    return buf[n];
 }
 
 void
diff --git a/skeletons/asn_system.h b/skeletons/asn_system.h
index eacacc4..ce46242 100644
--- a/skeletons/asn_system.h
+++ b/skeletons/asn_system.h
@@ -126,4 +126,21 @@
 #define RSSIZE_MAX   ((ssize_t)(RSIZE_MAX >> 1))
 #endif
 
+#if __STDC_VERSION__ >= 199901L
+#define ASN_PRI_SIZE "zu"
+#define ASN_PRI_SSIZE "zd"
+#define ASN_PRIuMAX PRIuMAX
+#define ASN_PRIdMAX PRIdMAX
+#else
+#define ASN_PRI_SIZE "lu"
+#define ASN_PRI_SSIZE "ld"
+#if LLONG_MAX > LONG_MAX
+#define ASN_PRIuMAX "llu"
+#define ASN_PRIdMAX "lld"
+#else
+#define ASN_PRIuMAX "lu"
+#define ASN_PRIdMAX "ld"
+#endif
+#endif
+
 #endif	/* ASN_SYSTEM_H */
diff --git a/skeletons/constr_SEQUENCE.c b/skeletons/constr_SEQUENCE.c
index bf4de7a..2fbf97b 100644
--- a/skeletons/constr_SEQUENCE.c
+++ b/skeletons/constr_SEQUENCE.c
@@ -202,7 +202,7 @@
 		/*
 		 * MICROPHASE 1: Synchronize decoding.
 		 */
-		ASN_DEBUG("In %s SEQUENCE left %d, edx=%zu flags=%d"
+		ASN_DEBUG("In %s SEQUENCE left %d, edx=%" ASN_PRI_SIZE " flags=%d"
 				" opt=%d ec=%d",
 			td->name, (int)ctx->left, edx,
 			elements[edx].flags, elements[edx].optional,
@@ -226,7 +226,7 @@
 		 * Fetch the T from TLV.
 		 */
 		tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag);
-		ASN_DEBUG("Current tag in %s SEQUENCE for element %zu "
+		ASN_DEBUG("Current tag in %s SEQUENCE for element %" ASN_PRI_SIZE " "
 			"(%s) is %s encoded in %d bytes, of frame %ld",
 			td->name, edx, elements[edx].name,
 			ber_tlv_tag_string(tlv_tag), (int)tag_len, (long)LEFT);
@@ -244,7 +244,7 @@
                     RETURN(RC_WMORE);
                 }
             } else if(((const uint8_t *)ptr)[1] == 0) {
-                ASN_DEBUG("edx = %zu, opt = %d, ec=%d", edx,
+                ASN_DEBUG("edx = %" ASN_PRI_SIZE ", opt = %d, ec=%d", edx,
                           elements[edx].optional, td->elements_count);
                 if((edx + elements[edx].optional == td->elements_count)
                    || IN_EXTENSION_GROUP(specs, edx)) {
@@ -342,7 +342,7 @@
 			 */
 			if(!IN_EXTENSION_GROUP(specs,
 				edx + elements[edx].optional)) {
-				ASN_DEBUG("Unexpected tag %s (at %zu)",
+				ASN_DEBUG("Unexpected tag %s (at %" ASN_PRI_SIZE ")",
 					ber_tlv_tag_string(tlv_tag), edx);
 				ASN_DEBUG("Expected tag %s (%s)%s",
 					ber_tlv_tag_string(elements[edx].tag),
@@ -355,7 +355,7 @@
 				ssize_t skip;
 				edx += elements[edx].optional;
 
-				ASN_DEBUG("Skipping unexpected %s (at %zu)",
+				ASN_DEBUG("Skipping unexpected %s (at %" ASN_PRI_SIZE ")",
 					ber_tlv_tag_string(tlv_tag), edx);
 				skip = ber_skip_length(opt_codec_ctx,
 					BER_TLV_CONSTRUCTED(ptr),
@@ -410,7 +410,7 @@
 					memb_ptr2, ptr, LEFT,
 					elements[edx].tag_mode);
 		}
-		ASN_DEBUG("In %s SEQUENCE decoded %zu %s of %d "
+		ASN_DEBUG("In %s SEQUENCE decoded %" ASN_PRI_SIZE " %s of %d "
 			"in %d bytes rval.code %d, size=%d",
 			td->name, edx, elements[edx].type->name,
 			(int)LEFT, (int)rval.consumed, rval.code, (int)size);
@@ -532,7 +532,7 @@
             memb_ptr2 =
                 (const void *const *)((const char *)sptr + elm->memb_offset);
             if(!*memb_ptr2) {
-				ASN_DEBUG("Element %s %zu not present",
+				ASN_DEBUG("Element %s %" ASN_PRI_SIZE " not present",
 					elm->name, edx);
 				if(elm->optional)
 					continue;
@@ -554,7 +554,7 @@
 		if(erval.encoded == -1)
 			return erval;
 		computed_size += erval.encoded;
-		ASN_DEBUG("Member %zu %s estimated %ld bytes",
+		ASN_DEBUG("Member %" ASN_PRI_SIZE " %s estimated %ld bytes",
 			edx, elm->name, (long)erval.encoded);
 	}
 
@@ -596,7 +596,7 @@
 		if(tmperval.encoded == -1)
 			return tmperval;
 		computed_size -= tmperval.encoded;
-		ASN_DEBUG("Member %zu %s of SEQUENCE %s encoded in %ld bytes",
+		ASN_DEBUG("Member %" ASN_PRI_SIZE " %s of SEQUENCE %s encoded in %ld bytes",
 			edx, elm->name, td->name, (long)tmperval.encoded);
 	}
 
@@ -782,7 +782,7 @@
 		case XCT_UNKNOWN_OP:
 		case XCT_UNKNOWN_BO:
 
-			ASN_DEBUG("XER/SEQUENCE: tcv=%d, ph=%d, edx=%zu",
+			ASN_DEBUG("XER/SEQUENCE: tcv=%d, ph=%d, edx=%" ASN_PRI_SIZE "",
 				tcv, ctx->phase, edx);
 			if(ctx->phase != 1) {
 				break;	/* Really unexpected */
@@ -820,7 +820,7 @@
 				if(n != edx_end)
 					continue;
 			} else {
-				ASN_DEBUG("Out of defined members: %zu/%u",
+				ASN_DEBUG("Out of defined members: %" ASN_PRI_SIZE "/%u",
 					edx, td->elements_count);
 			}
 
@@ -828,7 +828,7 @@
 			if(IN_EXTENSION_GROUP(specs,
 				edx + (edx < td->elements_count
 					? elements[edx].optional : 0))) {
-				ASN_DEBUG("Got anticipated extension at %zu",
+				ASN_DEBUG("Got anticipated extension at %" ASN_PRI_SIZE "",
 					edx);
 				/*
 				 * Check for (XCT_BOTH or XCT_UNKNOWN_BO)
@@ -1197,7 +1197,7 @@
 		bmlength = uper_get_nslength(pd);
 		if(bmlength < 0) ASN__DECODE_STARVED;
 
-		ASN_DEBUG("Extensions %zd present in %s", bmlength, td->name);
+		ASN_DEBUG("Extensions %" ASN_PRI_SSIZE " present in %s", bmlength, td->name);
 
 		epres = (uint8_t *)MALLOC((bmlength + 15) >> 3);
 		if(!epres) ASN__DECODE_STARVED;
@@ -1331,7 +1331,7 @@
 			present = 1;
 		}
 
-        ASN_DEBUG("checking %s:%s (@%zu) present => %d", elm->name,
+        ASN_DEBUG("checking %s:%s (@%" ASN_PRI_SIZE ") present => %d", elm->name,
                   elm->type->name, edx, present);
         exts_count++;
         exts_present += present;
@@ -1439,7 +1439,7 @@
             memb_ptr2 =
                 (const void *const *)((const char *)sptr + elm->memb_offset);
             if(!*memb_ptr2) {
-				ASN_DEBUG("Element %s %zu not present",
+				ASN_DEBUG("Element %s %" ASN_PRI_SIZE " not present",
 					elm->name, edx);
 				if(elm->optional)
 					continue;
diff --git a/skeletons/constr_SEQUENCE_oer.c b/skeletons/constr_SEQUENCE_oer.c
index 85310a4..4f290a1 100644
--- a/skeletons/constr_SEQUENCE_oer.c
+++ b/skeletons/constr_SEQUENCE_oer.c
@@ -131,7 +131,7 @@
         ASN_DEBUG("OER SEQUENCE %s Decoding PHASE 0", td->name);
 
         ASN_DEBUG(
-            "Expecting preamble bits %zu for %s (including %d extension bits)",
+            "Expecting preamble bits %" ASN_PRI_SIZE " for %s (including %d extension bits)",
             preamble_bits, td->name, has_extensions_bit);
 
         if(preamble_bytes > size) {
diff --git a/skeletons/constr_SET.c b/skeletons/constr_SET.c
index c54b5de..79b3fa7 100644
--- a/skeletons/constr_SET.c
+++ b/skeletons/constr_SET.c
@@ -235,7 +235,7 @@
 			 */
 			edx = t2m->el_no;
 			ctx->step = (edx << 1) + 1;
-			ASN_DEBUG("Got tag %s (%s), edx %zd",
+			ASN_DEBUG("Got tag %s (%s), edx %" ASN_PRI_SSIZE "",
 				ber_tlv_tag_string(tlv_tag), td->name, edx);
 		} else if(specs->extensible == 0) {
 			ASN_DEBUG("Unexpected tag %s "
@@ -273,7 +273,7 @@
 		 * already decoded elements.
 		 */
 		if(ASN_SET_ISPRESENT2((char *)st + specs->pres_offset, edx)) {
-			ASN_DEBUG("SET %s: Duplicate element %s (%zd)",
+			ASN_DEBUG("SET %s: Duplicate element %s (%" ASN_PRI_SSIZE ")",
 				td->name, elements[edx].name, edx);
 			RETURN(RC_FAIL);
 		}
@@ -678,7 +678,7 @@
 
 			if(ASN_SET_ISPRESENT2((char *)st + specs->pres_offset,
 					edx)) {
-				ASN_DEBUG("SET %s: Duplicate element %s (%zd)",
+				ASN_DEBUG("SET %s: Duplicate element %s (%" ASN_PRI_SSIZE ")",
 				td->name, elements[edx].name, edx);
 				RETURN(RC_FAIL);
 			}
diff --git a/skeletons/constr_SET_OF_oer.c b/skeletons/constr_SET_OF_oer.c
index d139fe9..caabcff 100644
--- a/skeletons/constr_SET_OF_oer.c
+++ b/skeletons/constr_SET_OF_oer.c
@@ -153,7 +153,7 @@
         case -1:
             RETURN(RC_FAIL);
         default:
-    ASN_DEBUG("ptr[] = %02x, advancing %zu, length=%zu", *(const uint8_t *)ptr, len_size, length);
+    ASN_DEBUG("ptr[] = %02x, advancing %" ASN_PRI_SIZE ", length=%" ASN_PRI_SIZE "", *(const uint8_t *)ptr, len_size, length);
             ADVANCE(len_size);
             ctx->left = length;
         }
diff --git a/skeletons/converter-example.c b/skeletons/converter-example.c
index 5c86d4b..a1dc37b 100644
--- a/skeletons/converter-example.c
+++ b/skeletons/converter-example.c
@@ -90,7 +90,7 @@
 #endif  /* JUNKTEST */
 
 /* Debug output function */
-static void
+static void CC_PRINTFLIKE(1, 2)
 DEBUG(const char *fmt, ...) {
     va_list ap;
     if(!opt_debug) return;
@@ -491,7 +491,7 @@
                     asn_fprint(stderr, pduType, structure);
                     exit(EX_UNAVAILABLE);
                 }
-                DEBUG("Encoded in %zd bytes of %s", erv.encoded,
+                DEBUG("Encoded in %" ASN_PRI_SSIZE " bytes of %s", erv.encoded,
                       ats_simple_name(osyntax));
             }
 
@@ -529,13 +529,14 @@
     uint8_t *p = DynamicBuffer.data + DynamicBuffer.offset;
     uint8_t *e = p + DynamicBuffer.length - (DynamicBuffer.unbits ? 1 : 0);
     if(!opt_debug) return;
-    DEBUG("Buffer: { d=%p, o=%ld, l=%ld, u=%ld, a=%ld, s=%ld }",
-        DynamicBuffer.data,
-        (long)DynamicBuffer.offset,
-        (long)DynamicBuffer.length,
-        (long)DynamicBuffer.unbits,
-        (long)DynamicBuffer.allocated,
-        (long)DynamicBuffer.bytes_shifted);
+    DEBUG("Buffer: { d=%p, o=%" ASN_PRI_SIZE ", l=%" ASN_PRI_SIZE
+          ", u=%" ASN_PRI_SIZE ", a=%" ASN_PRI_SIZE ", s=%" ASN_PRI_SIZE " }",
+        (const void *)DynamicBuffer.data,
+        DynamicBuffer.offset,
+        DynamicBuffer.length,
+        DynamicBuffer.unbits,
+        DynamicBuffer.allocated,
+        (size_t)DynamicBuffer.bytes_shifted);
     for(; p < e; p++) {
         fprintf(stderr, " %c%c%c%c%c%c%c%c",
             ((*p >> 7) & 1) ? '1' : '0',
@@ -552,9 +553,9 @@
         fprintf(stderr, " ");
         for(shift = 7; shift >= DynamicBuffer.unbits; shift--)
             fprintf(stderr, "%c", ((*p >> shift) & 1) ? '1' : '0');
-        fprintf(stderr, " %ld:%ld\n",
-            (long)DynamicBuffer.length - 1,
-            (long)8 - DynamicBuffer.unbits);
+        fprintf(stderr, " %" ASN_PRI_SSIZE ":%" ASN_PRI_SSIZE "\n",
+                (ssize_t)DynamicBuffer.length - 1,
+                (ssize_t)8 - DynamicBuffer.unbits);
     } else {
         fprintf(stderr, " %ld\n", (long)DynamicBuffer.length);
     }
@@ -633,7 +634,7 @@
     }
     *ptr <<= bits;
 
-    DEBUG("Unbits [%d=>", (int)DynamicBuffer.unbits);
+    DEBUG("Unbits [%" ASN_PRI_SIZE "=>", DynamicBuffer.unbits);
     if(DynamicBuffer.unbits == 0) {
         DynamicBuffer.unbits += bits;
     } else {
@@ -644,16 +645,15 @@
             DynamicBuffer.bytes_shifted++;
         }
     }
-    DEBUG("Unbits =>%d]", (int)DynamicBuffer.unbits);
+    DEBUG("Unbits =>%" ASN_PRI_SIZE "]", DynamicBuffer.unbits);
 
     buffer_dump();
 
-    DEBUG("Shifted. Now (o=%ld, u=%ld l=%ld)",
-        (long)DynamicBuffer.offset,
-        (long)DynamicBuffer.unbits,
-        (long)DynamicBuffer.length);
-    
-
+    DEBUG("Shifted. Now (o=%" ASN_PRI_SIZE ", u=%" ASN_PRI_SIZE
+          " l=%" ASN_PRI_SIZE ")",
+        DynamicBuffer.offset,
+        DynamicBuffer.unbits,
+        DynamicBuffer.length);
 }
 
 /*
@@ -663,15 +663,16 @@
 
     if(bytes == 0) return;
 
-    DEBUG("=> add_bytes(%ld) { o=%ld l=%ld u=%ld, s=%ld }",
-        (long)bytes,
-        (long)DynamicBuffer.offset,
-        (long)DynamicBuffer.length,
-        (long)DynamicBuffer.unbits,
-        (long)DynamicBuffer.allocated);
+    DEBUG("=> add_bytes(%" ASN_PRI_SIZE ") { o=%" ASN_PRI_SIZE
+          " l=%" ASN_PRI_SIZE " u=%" ASN_PRI_SIZE ", s=%" ASN_PRI_SIZE " }",
+        bytes,
+        DynamicBuffer.offset,
+        DynamicBuffer.length,
+        DynamicBuffer.unbits,
+        DynamicBuffer.allocated);
 
     if(DynamicBuffer.allocated
-    >= (DynamicBuffer.offset + DynamicBuffer.length + bytes)) {
+       >= (DynamicBuffer.offset + DynamicBuffer.length + bytes)) {
         DEBUG("\tNo buffer reallocation is necessary");
     } else if(bytes <= DynamicBuffer.offset) {
         DEBUG("\tContents shifted by %ld", DynamicBuffer.offset);
@@ -711,12 +712,13 @@
         buffer_shift_left(DynamicBuffer.length - bytes, bits);
     }
 
-    DEBUG("<= add_bytes(%ld) { o=%ld l=%ld u=%ld, s=%ld }",
-        (long)bytes,
-        (long)DynamicBuffer.offset,
-        (long)DynamicBuffer.length,
-        (long)DynamicBuffer.unbits,
-        (long)DynamicBuffer.allocated);
+    DEBUG("<= add_bytes(%" ASN_PRI_SIZE ") { o=%" ASN_PRI_SIZE
+          " l=%" ASN_PRI_SIZE " u=%" ASN_PRI_SIZE ", s=%" ASN_PRI_SIZE " }",
+        bytes,
+        DynamicBuffer.offset,
+        DynamicBuffer.length,
+        DynamicBuffer.unbits,
+        DynamicBuffer.allocated);
 }
 
 static int
@@ -803,7 +805,7 @@
             i_size = rd;
         }
 
-        DEBUG("Decoding %ld bytes", (long)i_size);
+        DEBUG("Decoding %" ASN_PRI_SIZE " bytes", i_size);
 
 #ifdef    JUNKTEST
         junk_bytes_with_probability(i_bptr, i_size, opt_jprob);
@@ -833,10 +835,9 @@
             /* Continue accumulating data */
         }
 
-        DEBUG("decode(%ld) consumed %ld+%db (%ld), code %d",
-            (long)DynamicBuffer.length,
-            (long)rval.consumed, ecbits, (long)i_size,
-            rval.code);
+        DEBUG("decode(%" ASN_PRI_SIZE ") consumed %" ASN_PRI_SIZE
+              "+%db (%" ASN_PRI_SIZE "), code %d",
+              DynamicBuffer.length, rval.consumed, ecbits, i_size, rval.code);
 
         if(DynamicBuffer.allocated == 0) {
             /*
diff --git a/skeletons/oer_encoder.c b/skeletons/oer_encoder.c
index 1a691ed..895aed4 100644
--- a/skeletons/oer_encoder.c
+++ b/skeletons/oer_encoder.c
@@ -89,7 +89,7 @@
 
     if(!st) ASN__ENCODE_FAILED;
 
-    ASN_DEBUG("Encoding %s (%zu bytes)", td ? td->name : "", st->size);
+    ASN_DEBUG("Encoding %s (%" ASN_PRI_SIZE " bytes)", td ? td->name : "", st->size);
 
     /*
      * X.696 (08/2015) #27.2
diff --git a/skeletons/per_opentype.c b/skeletons/per_opentype.c
index 353766a..f86dad7 100644
--- a/skeletons/per_opentype.c
+++ b/skeletons/per_opentype.c
@@ -38,19 +38,20 @@
     size = uper_encode_to_new_buffer(td, constraints, sptr, &buf);
     if(size <= 0) return -1;
 
-    ASN_DEBUG("Open type put %s of length %zd + overhead (1byte?)", td->name,
+    ASN_DEBUG("Open type put %s of length %" ASN_PRI_SSIZE " + overhead (1byte?)", td->name,
               size);
 
     bptr = buf;
     do {
         int need_eom = 0;
-        ssize_t maySave = uper_put_length(po, size, &need_eom);
-        ASN_DEBUG("Prepending length %zd to %s and allowing to save %d", size,
-                  td->name, (int)maySave);
-        if(maySave < 0) break;
-        if(per_put_many_bits(po, bptr, maySave * 8)) break;
-        bptr = (char *)bptr + maySave;
-        size -= maySave;
+        ssize_t may_save = uper_put_length(po, size, &need_eom);
+        ASN_DEBUG("Prepending length %" ASN_PRI_SSIZE
+                  " to %s and allowing to save %" ASN_PRI_SSIZE,
+                  size, td->name, may_save);
+        if(may_save < 0) break;
+        if(per_put_many_bits(po, bptr, may_save * 8)) break;
+        bptr = (char *)bptr + may_save;
+        size -= may_save;
         if(need_eom && uper_put_length(po, 0, 0)) {
             FREEMEM(buf);
             return -1;
diff --git a/skeletons/xer_encoder.c b/skeletons/xer_encoder.c
index 4b4891f..dff3c44 100644
--- a/skeletons/xer_encoder.c
+++ b/skeletons/xer_encoder.c
@@ -146,7 +146,7 @@
         if(opt_debug_stream) {
             fprintf(opt_debug_stream,
                     "Both structures encoded into the same XER byte stream "
-                    "of size %zu:\n%s",
+                    "of size %" ASN_PRI_SIZE ":\n%s",
                     xb1.buffer_size, xb1.buffer);
         }
     }
@@ -184,8 +184,8 @@
                   != (xb1.buffer_size - rval.consumed))) {
         if(opt_debug_stream) {
             fprintf(opt_debug_stream,
-                    "Round-trip decode of %s required less bytes (%zu) than "
-                    "encoded (%zu)\n",
+                    "Round-trip decode of %s required less bytes (%" ASN_PRI_SIZE ") than "
+                    "encoded (%" ASN_PRI_SIZE ")\n",
                     td->name, rval.consumed, xb1.buffer_size);
         }
         ASN_STRUCT_FREE(*td, sptr);