mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-19 17:30:27 +08:00
c: remove __CHAR_UNSIGNED__
In C, `char`, `signed char`, and `unsigned char` are three separate, distinct types, so just because `char` happens to be signed does not mean it is interchangeable with `signed char`.
This commit is contained in:
parent
7505bed6f5
commit
b432a527c4
@ -1186,20 +1186,6 @@ MARK_AS_ADVANCED(ENABLE_SHARED_LIBRARY_VERSION)
|
||||
# Option checks
|
||||
################################
|
||||
|
||||
####
|
||||
# Check to see if char is signed or unsigned.
|
||||
####
|
||||
|
||||
SET(SIGNED_TEST_SOURCE "\n
|
||||
#include <stdlib.h>\n
|
||||
int main(void) {\n
|
||||
char error_if_char_is_signed[((char)-1) < 0 ? -1 : 1];\n
|
||||
error_if_char_is_signed[0] = 0;
|
||||
return -;\n
|
||||
}\n")
|
||||
|
||||
CHECK_C_SOURCE_COMPILES("${SIGNED_TEST_SOURCE}" __CHAR_UNSIGNED__)
|
||||
|
||||
# Library include checks
|
||||
CHECK_INCLUDE_FILE("math.h" HAVE_MATH_H)
|
||||
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
|
||||
|
@ -553,11 +553,6 @@ are set when opening a binary file on Windows. */
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
#cmakedefine _LARGE_FILES ${_LARGE_FILES}
|
||||
|
||||
/* Define to 1 if type `char' is unsigned and you are not using gcc. */
|
||||
#ifndef __CHAR_UNSIGNED__
|
||||
#cmakedefine __CHAR_UNSIGNED__
|
||||
#endif
|
||||
|
||||
/* Define to `long int' if <sys/types.h> does not define. */
|
||||
#cmakedefine off_t long int
|
||||
|
||||
|
@ -196,11 +196,6 @@ are set when opening a binary file on Windows. */
|
||||
#cmakedefine SIZEOF_ULONGLONG @SIZEOF_ULONGLONG@
|
||||
#cmakedefine SIZEOF_UNSIGNED_LONG_LONG @SIZEOF_UNSIGNED_LONG_LONG@
|
||||
|
||||
/* Define whether char is signed by default. */
|
||||
#ifndef __CHAR_UNSIGNED__
|
||||
#cmakedefine __CHAR_UNSIGNED__
|
||||
#endif
|
||||
|
||||
/* The size of `void*` as computed by sizeof. */
|
||||
#cmakedefine SIZEOF_VOIDSTAR @SIZEOF_VOIDSTAR@
|
||||
/* The size of `char` as computed by sizeof. */
|
||||
|
@ -808,7 +808,6 @@ AC_STRUCT_ST_BLKSIZE
|
||||
UD_CHECK_IEEE
|
||||
AC_CHECK_TYPES([size_t, ssize_t, schar, uchar, longlong, ushort, uint, int64, uint64])
|
||||
AC_TYPE_OFF_T
|
||||
AC_C_CHAR_UNSIGNED
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
###
|
||||
|
@ -740,11 +740,7 @@ done:
|
||||
pxp->bf_rflags |= rflags;
|
||||
pxp->bf_refcount++;
|
||||
|
||||
#ifndef __CHAR_UNSIGNED__
|
||||
*vpp = (void *)((char *)pxp->bf_base + diff);
|
||||
#else
|
||||
*vpp = (void *)((signed char*)pxp->bf_base + diff);
|
||||
#endif
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
|
@ -1198,11 +1198,7 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
|
||||
|
||||
case CASE(NC_CHAR,NC_CHAR):
|
||||
case CASE(NC_CHAR,NC_UBYTE):
|
||||
#ifndef __CHAR_UNSIGNED__
|
||||
return getNCvx_char_char(ncp,varp,start,nelems,(char*)value);
|
||||
#else
|
||||
return getNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
|
||||
#endif
|
||||
break;
|
||||
case CASE(NC_BYTE,NC_BYTE):
|
||||
return getNCvx_schar_schar(ncp,varp,start,nelems, (schar*)value);
|
||||
|
@ -342,11 +342,7 @@ int dbl2nc ( const double d, const nc_type xtype, void *p)
|
||||
* reporting it as a range error.
|
||||
*/
|
||||
if ( r < X_CHAR_MIN || r > X_CHAR_MAX ) return 2;
|
||||
#if defined(__CHAR_UNSIGNED__) && __CHAR_UNSIGNED__ != 0
|
||||
*((signed char*) p) = (signed char)r;
|
||||
#else
|
||||
*((char *) p) = (char)r;
|
||||
#endif
|
||||
break;
|
||||
case NC_BYTE:
|
||||
r = floor(0.5+d);
|
||||
|
Loading…
x
Reference in New Issue
Block a user