GRIB-588: compile eccodes with a C++ compiler

This commit is contained in:
Shahram Najm 2014-10-11 18:44:22 +01:00
parent ec773964ed
commit f9b29d07ce
7 changed files with 27 additions and 31 deletions

View File

@ -400,7 +400,7 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
c=a->parent->h->context; c=a->parent->h->context;
if (size==0) return; if (size==0) return;
value=grib_context_malloc_clear(c,size); value=(char*)grib_context_malloc_clear(c,size);
if (!value) { if (!value) {
grib_context_log(c,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size); grib_context_log(c,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size);
return; return;
@ -542,7 +542,7 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
dump_double(d,a,NULL); dump_double(d,a,NULL);
return ; return ;
} }
buf = grib_context_malloc(d->handle->context,size * sizeof(double)); buf = (double*)grib_context_malloc(d->handle->context,size * sizeof(double));
print_offset(self->dumper.out,d,a); print_offset(self->dumper.out,d,a);

View File

@ -287,7 +287,7 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
char *p=NULL; char *p=NULL;
int err = _grib_get_string_length(a,&size); int err = _grib_get_string_length(a,&size);
value=grib_context_malloc_clear(a->parent->h->context,size); value=(char*)grib_context_malloc_clear(a->parent->h->context,size);
if (!value) { if (!value) {
grib_context_log(a->parent->h->context,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size); grib_context_log(a->parent->h->context,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size);
return; return;

View File

@ -135,7 +135,7 @@ static grib_trie* load_dictionary(grib_context* c,grib_expression* e, int* err)
i++; i++;
} }
key[i]=0; key[i]=0;
list=grib_context_malloc_clear(c,strlen(line)+1); list=(char*)grib_context_malloc_clear(c,strlen(line)+1);
memcpy(list,line,strlen(line)); memcpy(list,line,strlen(line));
grib_trie_insert(dictionary,key,list); grib_trie_insert(dictionary,key,list);
} }

View File

@ -51,9 +51,7 @@ struct grib_keys_hash { char* name; int id;};
#endif #endif
#endif #endif
static unsigned int static unsigned int
hash_keys (str, len) hash_keys (const char *str, unsigned int len)
register const char *str;
register unsigned int len;
{ {
static unsigned short asso_values[] = static unsigned short asso_values[] =
{ {
@ -7310,9 +7308,7 @@ static struct grib_keys_hash wordlist[] =
#endif #endif
#endif #endif
struct grib_keys_hash * struct grib_keys_hash *
grib_keys_hash_get (str, len) grib_keys_hash_get (const char *str, unsigned int len)
register const char *str;
register unsigned int len;
{ {
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{ {
@ -7625,7 +7621,7 @@ struct grib_itrie {
grib_itrie *grib_hash_keys_new(grib_context* c,int* count) { grib_itrie *grib_hash_keys_new(grib_context* c,int* count) {
grib_itrie* t = grib_context_malloc_clear(c,sizeof(grib_itrie)); grib_itrie* t = (grib_itrie*)grib_context_malloc_clear(c,sizeof(grib_itrie));
t->context = c; t->context = c;
t->id=-1; t->id=-1;
t->count=count; t->count=count;

View File

@ -949,7 +949,7 @@ int codes_index_add_file(grib_index* index,const char* filename,int message_type
if (!index->files) { if (!index->files) {
grib_filesid++; grib_filesid++;
newfile=grib_context_malloc_clear(c,sizeof(grib_file)); newfile=(grib_file*)grib_context_malloc_clear(c,sizeof(grib_file));
newfile->id=grib_filesid; newfile->id=grib_filesid;
newfile->name=strdup(file->name); newfile->name=strdup(file->name);
index->files=newfile; index->files=newfile;
@ -962,7 +962,7 @@ int codes_index_add_file(grib_index* index,const char* filename,int message_type
indfile=index->files; indfile=index->files;
while(indfile->next) indfile=indfile->next; while(indfile->next) indfile=indfile->next;
grib_filesid++; grib_filesid++;
newfile=grib_context_malloc_clear(c,sizeof(grib_file)); newfile=(grib_file*)grib_context_malloc_clear(c,sizeof(grib_file));
newfile->id=grib_filesid; newfile->id=grib_filesid;
newfile->name=strdup(file->name); newfile->name=strdup(file->name);
indfile->next=newfile; indfile->next=newfile;
@ -1015,7 +1015,7 @@ int codes_index_add_file(grib_index* index,const char* filename,int message_type
if (strcmp(v->value,buf)) { if (strcmp(v->value,buf)) {
index_key->values_count++; index_key->values_count++;
if (v->next) v=v->next; if (v->next) v=v->next;
v->next=grib_context_malloc_clear(c,sizeof(grib_string_list)); v->next=(grib_string_list*)grib_context_malloc_clear(c,sizeof(grib_string_list));
v->next->value=grib_context_strdup(c,buf); v->next->value=grib_context_strdup(c,buf);
} }
} }
@ -1040,14 +1040,14 @@ int codes_index_add_file(grib_index* index,const char* filename,int message_type
if (index_key->next) { if (index_key->next) {
if (!field_tree->next_level) { if (!field_tree->next_level) {
field_tree->next_level= field_tree->next_level=
grib_context_malloc_clear(c,sizeof(grib_field_tree)); (grib_field_tree*)grib_context_malloc_clear(c,sizeof(grib_field_tree));
} }
field_tree=field_tree->next_level; field_tree=field_tree->next_level;
} }
index_key=index_key->next; index_key=index_key->next;
} }
field=grib_context_malloc_clear(c,sizeof(grib_field)); field=(grib_field*)grib_context_malloc_clear(c,sizeof(grib_field));
field->file=file; field->file=file;
index->count++; index->count++;
field->offset=h->offset;; field->offset=h->offset;;
@ -1662,7 +1662,7 @@ grib_handle* codes_new_from_index(grib_index* index,int message_type,int *err)
} }
if (!index->fieldset) { if (!index->fieldset) {
index->fieldset=grib_context_malloc_clear(index->context, index->fieldset=(grib_field_list*)grib_context_malloc_clear(index->context,
sizeof(grib_field_list)); sizeof(grib_field_list));
if (!index->fieldset) { if (!index->fieldset) {
grib_context_log(index->context,GRIB_LOG_ERROR, grib_context_log(index->context,GRIB_LOG_ERROR,

View File

@ -248,11 +248,11 @@ int grib_tool_init(grib_runtime_options* options) {
if (grib_options_on("b:")) { if (grib_options_on("b:")) {
grib_string_list *next=0; grib_string_list *next=0;
int i=0; int i=0;
blacklist=grib_context_malloc_clear(context,sizeof(grib_string_list)); blacklist=(grib_string_list*)grib_context_malloc_clear(context,sizeof(grib_string_list));
blacklist->value=grib_context_strdup(context,options->set_values[0].name); blacklist->value=grib_context_strdup(context,options->set_values[0].name);
next=blacklist; next=blacklist;
for (i=1;i<options->set_values_count;i++) { for (i=1;i<options->set_values_count;i++) {
next->next=grib_context_malloc_clear(context,sizeof(grib_string_list)); next->next=(grib_string_list*)grib_context_malloc_clear(context,sizeof(grib_string_list));
next->next->value=grib_context_strdup(context,options->set_values[i].name); next->next->value=grib_context_strdup(context,options->set_values[i].name);
next=next->next; next=next->next;
} }
@ -490,7 +490,7 @@ static void save_error(grib_context* c,const char* key) {
int saved=0; int saved=0;
if (!error_summary) { if (!error_summary) {
error_summary=grib_context_malloc_clear(c,sizeof(grib_error)); error_summary=(grib_error*)grib_context_malloc_clear(c,sizeof(grib_error));
error_summary->count=1; error_summary->count=1;
error_summary->key=grib_context_strdup(c,key); error_summary->key=grib_context_strdup(c,key);
return; return;
@ -510,7 +510,7 @@ static void save_error(grib_context* c,const char* key) {
} }
if (!saved) { if (!saved) {
e->next=grib_context_malloc_clear(c,sizeof(grib_error)); e->next=(grib_error*)grib_context_malloc_clear(c,sizeof(grib_error));
e->next->count=1; e->next->count=1;
e->next->key=grib_context_strdup(c,key); e->next->key=grib_context_strdup(c,key);
} }
@ -650,8 +650,8 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
if (verbose) printf(" as string\n"); if (verbose) printf(" as string\n");
grib_get_string_length(h1,name,&len1); grib_get_string_length(h1,name,&len1);
grib_get_string_length(h2,name,&len2); grib_get_string_length(h2,name,&len2);
sval1 = grib_context_malloc(h1->context,len1*sizeof(char)); sval1 = (char*)grib_context_malloc(h1->context,len1*sizeof(char));
sval2 = grib_context_malloc(h2->context,len2*sizeof(char)); sval2 = (char*)grib_context_malloc(h2->context,len2*sizeof(char));
if((err1 = grib_get_string(h1,name,sval1,&len1)) != GRIB_SUCCESS) if((err1 = grib_get_string(h1,name,sval1,&len1)) != GRIB_SUCCESS)
{ {
@ -692,8 +692,8 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
case GRIB_TYPE_LONG: case GRIB_TYPE_LONG:
if (verbose) printf(" as long\n"); if (verbose) printf(" as long\n");
lval1 = grib_context_malloc(h1->context,len1*sizeof(long)); lval1 = (long*)grib_context_malloc(h1->context,len1*sizeof(long));
lval2 = grib_context_malloc(h2->context,len2*sizeof(long)); lval2 = (long*)grib_context_malloc(h2->context,len2*sizeof(long));
if((err1 = grib_get_long_array(h1,name,lval1,&len1)) != GRIB_SUCCESS) if((err1 = grib_get_long_array(h1,name,lval1,&len1)) != GRIB_SUCCESS)
{ {
@ -742,8 +742,8 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
case GRIB_TYPE_DOUBLE: case GRIB_TYPE_DOUBLE:
if (verbose) printf(" as double"); if (verbose) printf(" as double");
dval1 = grib_context_malloc(h1->context,len1*sizeof(double)); dval1 = (double*)grib_context_malloc(h1->context,len1*sizeof(double));
dval2 = grib_context_malloc(h2->context,len2*sizeof(double)); dval2 = (double*)grib_context_malloc(h2->context,len2*sizeof(double));
isangle=0; isangle=0;
value_tolerance=global_tolerance; value_tolerance=global_tolerance;
@ -882,8 +882,8 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
if (options->mode==MODE_BUFR) return 0; if (options->mode==MODE_BUFR) return 0;
if (len1==0) len1=512; if (len1==0) len1=512;
if (len2==0) len2=512; if (len2==0) len2=512;
uval1 = grib_context_malloc(h1->context,len1*sizeof(unsigned char)); uval1 = (unsigned char*)grib_context_malloc(h1->context,len1*sizeof(unsigned char));
uval2 = grib_context_malloc(h2->context,len2*sizeof(unsigned char)); uval2 = (unsigned char*)grib_context_malloc(h2->context,len2*sizeof(unsigned char));
if((err1 = grib_get_bytes(h1,name,uval1,&len1)) != GRIB_SUCCESS) if((err1 = grib_get_bytes(h1,name,uval1,&len1)) != GRIB_SUCCESS)
{ {

View File

@ -381,7 +381,7 @@ static int navigate(grib_field_tree* fields,grib_runtime_options* options)
if (fields->field) { if (fields->field) {
grib_handle* h=codes_index_get_handle(fields->field,message_type,&err); grib_handle* h=codes_index_get_handle(fields->field,message_type,&err);
if (!options->index2->current) if (!options->index2->current)
options->index2->current=grib_context_malloc_clear(options->context,sizeof(grib_field_list)); options->index2->current=(grib_field_list*)grib_context_malloc_clear(options->context,sizeof(grib_field_list));
options->index2->current->field=fields->field; options->index2->current->field=fields->field;
if (!h) return err; if (!h) return err;
grib_skip_check(options,h); grib_skip_check(options,h);
@ -867,7 +867,7 @@ void grib_print_key_values(grib_runtime_options* options,grib_handle* h)
if (!options->fail) exit(err); if (!options->fail) exit(err);
return; return;
} }
values=grib_context_malloc_clear(h->context,size*sizeof(double)); values=(double*)grib_context_malloc_clear(h->context,size*sizeof(double));
grib_get_double_array(h,"values",values,&size); grib_get_double_array(h,"values",values,&size);
the_index = options->index; the_index = options->index;
if (the_index >= size) { if (the_index >= size) {