This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Joe, In the C++ documentation, we said for ncbyte: ncbyte Used to declare values of type ncByte, for 8-bit integer data. (This is currently a typedef for unsigned char, but it may be changed to a typedef for signed char, so don't depend on the underlying representation.) Although it's legal in C++ to assign a signed value to an unsigned type (and g++ -Wall doesn't even warn about it), it does raise questions why we did it this way. The answer is that originally ncbyte was just a typedef for "char", and different platforms interpreted it as either signed or unsigned, depending on their default for "char" types in C. Then we changed from netCDF-2 interfaces which were not type-safe to netCDF-3 interfaces which were type-safe and permitted requesting conversion on-the-fly of numeric values from one type to a different numeric type when reading data. This required for interoperability that we pin down an interpretation for ncbyte in order to support its conversion to int, for example. We picked "signed", but the C++ interface was still based on the netCDF-2 C interface, so it was not changed. Nevertheless, since we warned users in the documentation that the underlying type for ncbyte would change, the time has come to make this consistent with the C interface. The next beta release will define ncbyte as signed char in the C++ interface. If we don't get cries of anguish about breaking anything, this change will be in the 3.6.2 and subsequent releases. Thanks for your comments. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: CZF-138501 Department: Support netCDF Priority: Critical Status: Closed