30 #define NORETURN __declspec(noreturn) 32 #define NORETURN __attribute__((noreturn)) 39 #if defined(__cplusplus) && __cplusplus >= 201703L 40 #define NINJA_FALLTHROUGH [[fallthrough]] 41 #elif defined(__cplusplus) && __cplusplus >= 201103L && defined(__clang__) 42 #define NINJA_FALLTHROUGH [[clang::fallthrough]] 43 #elif defined(__cplusplus) && __cplusplus >= 201103L && defined(__GNUC__) && \ 45 #define NINJA_FALLTHROUGH [[gnu::fallthrough]] 46 #elif defined(__GNUC__) && __GNUC__ >= 7 // gcc 7 47 #define NINJA_FALLTHROUGH __attribute__ ((fallthrough)) 48 #else // C++11 on gcc 6, and all other cases 49 #define NINJA_FALLTHROUGH 53 void Warning(
const char* msg, ...);
54 void Warning(
const char* msg, va_list ap);
57 void Error(
const char* msg, ...);
58 void Error(
const char* msg, va_list ap);
61 void Info(
const char* msg, ...);
62 void Info(
const char* msg, va_list ap);
80 int ReadFile(
const std::string& path, std::string* contents, std::string* err);
88 const std::vector<const char*>& words);
108 std::string
ElideMiddle(
const std::string& str,
size_t width);
111 bool Truncate(
const std::string& path,
size_t size, std::string* err);
114 #define snprintf _snprintf 115 #define fileno _fileno 116 #define unlink _unlink 118 #define strtoull _strtoui64 119 #define getcwd _getcwd 120 #define PATH_MAX _MAX_PATH 125 std::string GetLastErrorString();
128 NORETURN void Win32Fatal(
const char*
function,
const char* hint = NULL);
131 #endif // NINJA_UTIL_H_ void GetWin32EscapedString(const std::string &input, std::string *result)
const char * SpellcheckStringV(const std::string &text, const std::vector< const char *> &words)
Given a misspelled string and a list of correct spellings, returns the closest match or NULL if there...
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 Truncate(const std::string &path, size_t size, std::string *err)
Truncates a file to the given size.
void CanonicalizePath(std::string *path, uint64_t *slash_bits)
Canonicalize a path like "foo/../bar.h" into just "bar.h".
void Warning(const char *msg,...)
Log a warning message.
std::string StripAnsiEscapeCodes(const std::string &in)
Removes all Ansi escape codes (http://www.termsys.demon.co.uk/vtansi.htm).
std::string ElideMiddle(const std::string &str, size_t width)
Elide the given string str with '...' in the middle if the length exceeds width.
void GetShellEscapedString(const std::string &input, std::string *result)
Appends |input| to |*result|, escaping according to the whims of either Bash, or Win32's CommandLineT...
void Info(const char *msg,...)
Log an informational message.
unsigned long long uint64_t
void SetCloseOnExec(int fd)
Mark a file descriptor to not be inherited on exec()s.
int ReadFile(const std::string &path, std::string *contents, std::string *err)
Read a file to a string (in text mode: with CRLF conversion on Windows).