29 #define NORETURN __declspec(noreturn) 31 #define NORETURN __attribute__((noreturn)) 38 #if defined(__cplusplus) && __cplusplus >= 201703L 39 #define NINJA_FALLTHROUGH [[fallthrough]] 40 #elif defined(__cplusplus) && __cplusplus >= 201103L && defined(__clang__) 41 #define NINJA_FALLTHROUGH [[clang::fallthrough]] 42 #elif defined(__cplusplus) && __cplusplus >= 201103L && defined(__GNUC__) && \ 44 #define NINJA_FALLTHROUGH [[gnu::fallthrough]] 45 #elif defined(__GNUC__) && __GNUC__ >= 7 // gcc 7 46 #define NINJA_FALLTHROUGH __attribute__ ((fallthrough)) 47 #else // C++11 on gcc 6, and all other cases 48 #define NINJA_FALLTHROUGH 52 void Warning(
const char* msg, ...);
55 void Error(
const char* msg, ...);
74 int ReadFile(
const string& path,
string* contents,
string* err);
82 const vector<const char*>& words);
102 string ElideMiddle(
const string& str,
size_t width);
105 bool Truncate(
const string& path,
size_t size,
string* err);
108 #define snprintf _snprintf 109 #define fileno _fileno 110 #define unlink _unlink 112 #define strtoull _strtoui64 113 #define getcwd _getcwd 114 #define PATH_MAX _MAX_PATH 119 string GetLastErrorString();
122 NORETURN void Win32Fatal(
const char*
function,
const char* hint = NULL);
125 #endif // NINJA_UTIL_H_ void GetWin32EscapedString(const string &input, string *result)
const char * SpellcheckString(const char *text,...)
Like SpellcheckStringV, but takes a NULL-terminated list.
void Error(const char *msg,...)
Log an error message.
NORETURN void Fatal(const char *msg,...)
Log a fatal message and exit.
bool CanonicalizePath(string *path, uint64_t *slash_bits, string *err)
Canonicalize a path like "foo/../bar.h" into just "bar.h".
bool Truncate(const string &path, size_t size, string *err)
Truncates a file to the given size.
void Warning(const char *msg,...)
Log a warning message.
void GetShellEscapedString(const string &input, string *result)
Appends |input| to |*result|, escaping according to the whims of either Bash, or Win32's CommandLineT...
int ReadFile(const string &path, string *contents, string *err)
Read a file to a string (in text mode: with CRLF conversion on Windows).
string StripAnsiEscapeCodes(const string &in)
Removes all Ansi escape codes (http://www.termsys.demon.co.uk/vtansi.htm).
unsigned long long uint64_t
void SetCloseOnExec(int fd)
Mark a file descriptor to not be inherited on exec()s.
string ElideMiddle(const string &str, size_t width)
Elide the given string str with '...' in the middle if the length exceeds width.
const char * SpellcheckStringV(const string &text, const vector< const char *> &words)
Given a misspelled string and a list of correct spellings, returns the closest match or NULL if there...