adjusted definitions to include gcc 4.x into the supported compilers list
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@911 59561ff5-6e30-0410-9f3c-9617f08c8826
diff --git a/skeletons/NativeInteger.c b/skeletons/NativeInteger.c
index 2b13618..96c7875 100644
--- a/skeletons/NativeInteger.c
+++ b/skeletons/NativeInteger.c
@@ -91,8 +91,14 @@
*/
{
INTEGER_t tmp;
+ union {
+ const void *constbuf;
+ void *nonconstbuf;
+ } unconst_buf;
long l;
- (const uint8_t *)tmp.buf = (const uint8_t *)buf_ptr;
+
+ unconst_buf.constbuf = buf_ptr;
+ tmp.buf = (uint8_t *)unconst_buf.nonconstbuf;
tmp.size = length;
if(asn_INTEGER2long(&tmp, &l)) {
diff --git a/skeletons/NativeReal.c b/skeletons/NativeReal.c
index f2a3afc..f7755db 100644
--- a/skeletons/NativeReal.c
+++ b/skeletons/NativeReal.c
@@ -93,8 +93,14 @@
*/
{
REAL_t tmp;
+ union {
+ const void *constbuf;
+ void *nonconstbuf;
+ } unconst_buf;
double d;
- (const uint8_t *)tmp.buf = (const uint8_t *)buf_ptr;
+
+ unconst_buf.constbuf = buf_ptr;
+ tmp.buf = (uint8_t *)unconst_buf.nonconstbuf;
tmp.size = length;
if(asn_REAL2double(&tmp, &d)) {
diff --git a/skeletons/asn-decoder-template.c b/skeletons/asn-decoder-template.c
index 4a53bc9..5116529 100644
--- a/skeletons/asn-decoder-template.c
+++ b/skeletons/asn-decoder-template.c
@@ -28,7 +28,6 @@
int opt_debug; /* -d */
static int opt_check; /* -c */
-static int opt_print; /* -p */
static int opt_stack; /* -s */
static enum output_method {
OUT_NONE, /* No pretty-printing */
diff --git a/skeletons/asn_SET_OF.c b/skeletons/asn_SET_OF.c
index 5e268c0..3670677 100644
--- a/skeletons/asn_SET_OF.c
+++ b/skeletons/asn_SET_OF.c
@@ -6,14 +6,12 @@
#include <asn_SET_OF.h>
#include <errno.h>
-typedef A_SET_OF(void) asn_set;
-
/*
* Add another element into the set.
*/
int
asn_set_add(void *asn_set_of_x, void *ptr) {
- asn_set *as = (asn_set *)asn_set_of_x;
+ asn_anonymous_set_ *as = _A_SET_FROM_VOID(asn_set_of_x);
if(as == 0 || ptr == 0) {
errno = EINVAL; /* Invalid arguments */
@@ -43,7 +41,7 @@
void
asn_set_del(void *asn_set_of_x, int number, int _do_free) {
- asn_set *as = (asn_set *)asn_set_of_x;
+ asn_anonymous_set_ *as = _A_SET_FROM_VOID(asn_set_of_x);
if(as) {
void *ptr;
@@ -71,7 +69,7 @@
*/
void
asn_set_empty(void *asn_set_of_x) {
- asn_set *as = (asn_set *)asn_set_of_x;
+ asn_anonymous_set_ *as = _A_SET_FROM_VOID(asn_set_of_x);
if(as) {
if(as->array) {
diff --git a/skeletons/asn_internal.h b/skeletons/asn_internal.h
index 22011ef..4c16dc9 100644
--- a/skeletons/asn_internal.h
+++ b/skeletons/asn_internal.h
@@ -80,4 +80,16 @@
if(cb(" ", 4, app_key) < 0) return -1; \
} while(0)
+/*
+ * Cope with implicit conversions to/from void.
+ */
+#include <asn_SET_OF.h>
+#include <asn_SEQUENCE_OF.h>
+typedef A_SEQUENCE_OF(void) asn_anonymous_sequence_;
+typedef A_SET_OF(void) asn_anonymous_set_;
+#define _A_SET_FROM_VOID(ptr) ((asn_anonymous_set_ *)(ptr))
+#define _A_CSET_FROM_VOID(ptr) ((const asn_anonymous_set_ *)(ptr))
+#define _A_SEQUENCE_FROM_VOID(ptr) ((asn_anonymous_sequence_ *)(ptr))
+#define _A_CSEQUENCE_FROM_VOID(ptr) ((const asn_anonymous_sequence_ *)(ptr))
+
#endif /* _ASN_INTERNAL_H_ */
diff --git a/skeletons/constr_SEQUENCE_OF.c b/skeletons/constr_SEQUENCE_OF.c
index 027f5ec..d9763fc 100644
--- a/skeletons/constr_SEQUENCE_OF.c
+++ b/skeletons/constr_SEQUENCE_OF.c
@@ -14,7 +14,7 @@
int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
asn_TYPE_member_t *elm = td->elements;
- A_SEQUENCE_OF(void) *list;
+ asn_anonymous_sequence_ *list = _A_SEQUENCE_FROM_VOID(ptr);
size_t computed_size = 0;
ssize_t encoding_size = 0;
asn_enc_rval_t erval;
@@ -25,7 +25,6 @@
/*
* 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,
@@ -90,7 +89,7 @@
asn_enc_rval_t er;
asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics;
asn_TYPE_member_t *element = td->elements;
- A_SEQUENCE_OF(void) *list;
+ asn_anonymous_sequence_ *list = _A_SEQUENCE_FROM_VOID(sptr);
const char *mname = specs->as_XMLValueList
? 0 : ((*element->name)
? element->name : element->type->xml_tag);
@@ -102,7 +101,6 @@
er.encoded = 0;
- (void *)list = sptr;
for(i = 0; i < list->count; i++) {
asn_enc_rval_t tmper;
diff --git a/skeletons/constr_SET_OF.c b/skeletons/constr_SET_OF.c
index 1bae1f9..2d72fca 100644
--- a/skeletons/constr_SET_OF.c
+++ b/skeletons/constr_SET_OF.c
@@ -212,8 +212,7 @@
switch(rval.code) {
case RC_OK:
{
- A_SET_OF(void) *list;
- (void *)list = (void *)st;
+ asn_anonymous_set_ *list = _A_SET_FROM_VOID(st);
if(ASN_SET_ADD(list, ctx->ptr) != 0)
RETURN(RC_FAIL);
else
@@ -314,7 +313,7 @@
asn_TYPE_member_t *elm = td->elements;
asn_TYPE_descriptor_t *elm_type = elm->type;
der_type_encoder_f *der_encoder = elm_type->der_encoder;
- A_SET_OF(void) *list;
+ asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr);
size_t computed_size = 0;
ssize_t encoding_size = 0;
struct _el_buffer *encoded_els;
@@ -328,7 +327,6 @@
/*
* 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);
@@ -516,8 +514,7 @@
element->type, &ctx->ptr, elm_tag,
buf_ptr, size);
if(tmprval.code == RC_OK) {
- A_SET_OF(void) *list;
- (void *)list = (void *)st;
+ asn_anonymous_set_ *list = _A_SET_FROM_VOID(st);
if(ASN_SET_ADD(list, ctx->ptr) != 0)
RETURN(RC_FAIL);
ctx->ptr = 0;
@@ -642,7 +639,7 @@
asn_enc_rval_t er;
asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics;
asn_TYPE_member_t *element = td->elements;
- A_SET_OF(void) *list;
+ asn_anonymous_set_ *list = _A_SET_FROM_VOID(sptr);
const char *mname = specs->as_XMLValueList
? 0 : ((*element->name)
? element->name : element->type->xml_tag);
@@ -656,8 +653,6 @@
if(!sptr) _ASN_ENCODE_FAILED;
- (void *)list = sptr;
-
if(xcan) {
encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0]));
if(!encs) _ASN_ENCODE_FAILED;
@@ -747,7 +742,7 @@
SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f *cb, void *app_key) {
asn_TYPE_member_t *element = td->elements;
- const A_SET_OF(void) *list;
+ const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
int ret;
int i;
@@ -758,7 +753,6 @@
|| cb(" ::= {", 6, app_key) < 0)
return -1;
- (const void *)list = sptr;
for(i = 0; i < list->count; i++) {
const void *memb_ptr = list->array[i];
if(!memb_ptr) continue;
@@ -780,14 +774,13 @@
SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
if(td && ptr) {
asn_TYPE_member_t *element = td->elements;
- A_SET_OF(void) *list;
+ asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr);
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)
@@ -808,7 +801,7 @@
asn_app_consume_bytes_f *app_errlog, void *app_key) {
asn_TYPE_member_t *element = td->elements;
asn_constr_check_f *constr;
- const A_SET_OF(void) *list;
+ const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
int i;
if(!sptr) {
@@ -818,8 +811,6 @@
return -1;
}
- (const void *)list = sptr;
-
constr = element->memb_constraints;
if(!constr) constr = element->type->check_constraints;