make -pdu=auto a default
diff --git a/libasn1compiler/asn1c_save.c b/libasn1compiler/asn1c_save.c
index f302ceb..6a094f7 100644
--- a/libasn1compiler/asn1c_save.c
+++ b/libasn1compiler/asn1c_save.c
@@ -617,12 +617,16 @@
abuf_printf(buf, "/*\n * Generated by asn1c-" VERSION
" (http://lionet.info/asn1c)\n */\n\n");
+ abuf_printf(buf,
+ "struct asn_TYPE_descriptor_s;\t"
+ "/* Forward declaration */\n\n");
+
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
TQ_FOR(arg->expr, &(mod->members), next) {
if(include_type_to_pdu_collection(arg) == TI_NOT_INCLUDED) continue;
abuf_printf(buf,
- "extern asn_TYPE_descriptor_t "
+ "extern struct asn_TYPE_descriptor_s "
"asn_DEF_%s;\n",
asn1c_make_identifier(0, arg->expr, NULL));
}
@@ -724,10 +728,19 @@
static int
need_to_generate_pdu_collection(arg_t *arg) {
+ /* If -pdu=all or -pdu=auto are given, we need to generate one. */
if(arg->flags & (A1C_PDU_ALL|A1C_PDU_AUTO))
return 1;
- if(arg->flags & A1C_PDU_TYPE)
- return (pduTypes > 1) ? 1 : 0;
+
+ /*
+ * If no -pdu=... flags were given, need to do it, too,
+ * effectively producing -pdu=auto.
+ */
+ if(!(arg->flags & (A1C_PDU_ALL | A1C_PDU_AUTO | A1C_PDU_TYPE))) return 1;
+
+ if(arg->flags & A1C_PDU_TYPE) {
+ return (pduTypes > 1) ? 1 : 0;
+ }
return 0;
}
@@ -757,7 +770,11 @@
}
if((arg->flags & A1C_PDU_ALL)
+ /* -pdu=auto */
|| ((arg->flags & A1C_PDU_AUTO) && !arg->expr->_type_referenced)
+ /* No -pdu=... whatsoever, act as if -pdu=auto */
+ || (!(arg->flags & (A1C_PDU_ALL | A1C_PDU_AUTO | A1C_PDU_TYPE))
+ && !arg->expr->_type_referenced)
|| asn1c__pdu_type_lookup(arg->expr->Identifier)) {
return 1;
}