Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
ncport.h
Go to the documentation of this file.
1#ifndef NOTCURSES_NCPORT
2#define NOTCURSES_NCPORT
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8// Platform-dependent preprocessor material (includes and definitions) needed
9// to compile against Notcurses. A critical definition is htole(), which forces
10// 32-bit values to little-endian (as used in the nccell gcluster field). This
11// ought be defined so that it's a a no-op on little-endian builds.
12
13#ifndef __MINGW32__ // All but Windows
14#include <netinet/in.h>
15#endif
16
17#if defined(__linux__) // Linux
18#include <byteswap.h>
19#define htole(x) (__bswap_32(htonl(x)))
20#elif defined(__APPLE__) // macOS
21#include <libkern/OSByteOrder.h>
22#define htole(x) (OSSwapInt32(htonl(x)))
23#elif defined(__gnu_hurd__) // Hurd
24#include <string.h>
25#include <byteswap.h>
26#define htole(x) (__bswap_32(htonl(x)))
27#define wcwidth(w) 1 // FIXME lol, no
28#define wcswidth(w, s) (int)(wcslen(w)) // FIXME lol, no
29#elif defined(__MINGW32__) // Windows
30#include <string.h>
31#define wcwidth(w) 1 // FIXME lol, no
32#define wcswidth(w, s) (int)(wcslen(w)) // FIXME lol, no
33#define htole(x) (x) // FIXME are all windows installs LE? ugh
34#else // BSDs
35#include <sys/endian.h>
36#define htole(x) (bswap32(htonl(x)))
37#endif
38
39#ifdef __cplusplus
40} // extern "C"
41#endif
42
43#endif