The following example, from libsrc4/tst_opaques.c, creates a very simple opaque type.
/* Create a file that has an opaque attribute. */ if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; if (nc_def_opaque(ncid, BASE_SIZE, TYPE_NAME, &xtype)) ERR; /* Write an att. */ if (nc_put_att(ncid, NC_GLOBAL, ATT_NAME, xtype, DIM_LEN, data)) ERR; if (nc_close(ncid)) ERR;