[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #BCP-575554]: Error found



Hello,

The example found in the documentation is a shorter example that highlights the 
syntax; it is not meant to be a complete example.

For an example of working with compound types I would refer you to the file 
`nc_test4/tst_compounds.c`, as well as the tst_compounds2.c and 
tst_compounds3.c files in the same directory.  They provide a complete example 
of working with compound types, which should compile for you without problem.

I hope this helps!

-Ward

> Hello there,
> 
> I'm from Peru. I want to write netcdf file with compoused type so I found
> an example in the documentation page at.
> 
> https://www.unidata.ucar.edu/software/netcdf/docs/group__user__types.html#details
> 
> struct s1
> {
> int i1;
> int i2;
> };
> struct s1 data[DIM_LEN], data_in[DIM_LEN];
> if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
> if (nc_def_compound(ncid, sizeof(struct s1), SVC_REC, &typeid)) ERR;
> if (nc_insert_compound(ncid, typeid, BATTLES_WITH_KLINGONS,
> HOFFSET(struct s1, i1), NC_INT)) ERR;
> if (nc_insert_compound(ncid, typeid, DATES_WITH_ALIENS,
> HOFFSET(struct s1, i2), NC_INT)) ERR;
> if (nc_def_dim(ncid, STARDATE, DIM_LEN, &dimid)) ERR;
> if (nc_def_var(ncid, SERVICE_RECORD, typeid, 1, dimids, &varid)) ERR;
> if (nc_put_var(ncid, varid, data)) ERR;
> if (nc_close(ncid)) ERR;
> 
> But when I tried to compile for c. I found these messages. Also I attached
> my source file. Please, could you give me some advice?
> 
> simple_composed_wr.c: In function ‘main’:
> simple_composed_wr.c:66:4: warning: implicit declaration of function
> ‘HOFFSET’ [-Wimplicit-function-declaration]
> HOFFSET(struct s1, i1), NC_INT)) ERR;
> ^
> simple_composed_wr.c:66:12: error: expected expression before ‘struct’
> HOFFSET(struct s1, i1), NC_INT)) ERR;
> ^
> simple_composed_wr.c:68:12: error: expected expression before ‘struct’
> HOFFSET(struct s1, i2), NC_INT)) ERR;
> ^
> simple_composed_wr.c:69:25: error: ‘STARDATE’ undeclared (first use in this
> function)
> if (nc_def_dim(ncid, STARDATE, DIM_LEN, &dimid)) ERR;
> ^
> simple_composed_wr.c:69:25: note: each undeclared identifier is reported
> only once for each function it appears in
> simple_composed_wr.c:69:45: error: ‘dimid’ undeclared (first use in this
> function)
> if (nc_def_dim(ncid, STARDATE, DIM_LEN, &dimid)) ERR;
> ^
> simple_composed_wr.c:70:25: error: ‘SERVICE_RECORD’ undeclared (first use
> in this function)
> if (nc_def_var(ncid, SERVICE_RECORD, typeid, 1, dimids, &varid)) ERR;
> ^
> simple_composed_wr.c:70:52: error: ‘dimids’ undeclared (first use in this
> function)
> if (nc_def_var(ncid, SERVICE_RECORD, typeid, 1, dimids, &varid)) ERR;
> 
> 
> Regards
> Huber
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> https://www.unidata.ucar.edu/software/netcdf/docs/group__user__types.html#details
> 
> 


Ticket Details
===================
Ticket ID: BCP-575554
Department: Support netCDF
Priority: Normal
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.