Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Commit

Permalink
typedef ssize_t when POSIX not detected
Browse files Browse the repository at this point in the history
<sys/types.h> header is not part of ANSI C.
  • Loading branch information
hectr committed May 2, 2016
1 parent 5a84e53 commit f64a1c6
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions utf8proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,25 @@
/** @} */

#include <stdlib.h>
#include <sys/types.h>
#include <limits.h>
#if defined(_POSIX_VERSION) || defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
# include <sys/types.h>
#else
# include <stddef.h>
# include <stdint.h>
# if SIZE_MAX == USHRT_MAX
typedef short ssize_t;
# elif SIZE_MAX == UINT_MAX
typedef int ssize_t;
# elif SIZE_MAX == ULONG_MAX
typedef long ssize_t;
# elif SIZE_MAX == ULLONG_MAX
typedef long long ssize_t;
# else
# error ssize_t cannot be inferred from SIZE_MAX
# endif
#endif

#ifdef _MSC_VER
typedef signed char utf8proc_int8_t;
typedef unsigned char utf8proc_uint8_t;
Expand Down Expand Up @@ -110,7 +128,6 @@ typedef size_t utf8proc_size_t;
typedef ssize_t utf8proc_ssize_t;
typedef bool utf8proc_bool;
#endif
#include <limits.h>

#ifdef _WIN32
# ifdef UTF8PROC_EXPORTS
Expand Down

0 comments on commit f64a1c6

Please sign in to comment.