29 #if !defined(__has_cpp_attribute)
30 # define __has_cpp_attribute(x) 0
33 #if __has_cpp_attribute(noreturn)
34 # define NORETURN [[noreturn]]
43 #if __has_cpp_attribute(fallthrough)
44 # define NINJA_FALLTHROUGH [[fallthrough]]
45 #elif defined(__clang__)
46 # define NINJA_FALLTHROUGH [[clang::fallthrough]]
48 # define NINJA_FALLTHROUGH
52 void Warning(
const char* msg, ...);
53 void Warning(
const char* msg, va_list ap);
56 void Error(
const char* msg, ...);
57 void Error(
const char* msg, va_list ap);
60 void Info(
const char* msg, ...);
61 void Info(
const char* msg, va_list ap);
79 int ReadFile(
const std::string& path, std::string* contents, std::string* err);
87 const std::vector<const char*>& words);
109 bool Truncate(
const std::string& path,
size_t size, std::string* err);
112 #define snprintf _snprintf
113 #define fileno _fileno
115 #define strtoull _strtoui64
116 #define getcwd _getcwd
117 #define PATH_MAX _MAX_PATH
122 std::string GetLastErrorString();
125 NORETURN void Win32Fatal(
const char*
function,
const char* hint = NULL);
129 template <
class To,
class From>
130 inline To FunctionCast(From from) {
131 static_assert(
sizeof(To) ==
sizeof(From),
"");
133 memcpy(&result, &from,
sizeof(To));
void CanonicalizePath(std::string *path, uint64_t *slash_bits)
Canonicalize a path like "foo/../bar.h" into just "bar.h".
const char * SpellcheckString(const char *text,...)
Like SpellcheckStringV, but takes a NULL-terminated list.
int platformAwareUnlink(const char *filename)
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...
std::string GetWorkingDirectory()
a wrapper for getcwd()
void GetWin32EscapedString(const std::string &input, std::string *result)
void Error(const char *msg,...)
Log an error message.
void SetCloseOnExec(int fd)
Mark a file descriptor to not be inherited on exec()s.
bool Truncate(const std::string &path, size_t size, std::string *err)
Truncates a file to the given size.
void Warning(const char *msg,...)
Log a warning message.
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...
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).
void Info(const char *msg,...)
Log an informational message.
NORETURN void Fatal(const char *msg,...)
Log a fatal message and exit.
std::string StripAnsiEscapeCodes(const std::string &in)
Removes all Ansi escape codes (http://www.termsys.demon.co.uk/vtansi.htm).
unsigned long long uint64_t