diff --git a/interfaces/inner_api/event_handler.h b/interfaces/inner_api/event_handler.h index dafcdd8d96361b817062d200cb24b0dc35641efd..47cec1e221bea2b8ef4d3309a2b71b63c2553be8 100644 --- a/interfaces/inner_api/event_handler.h +++ b/interfaces/inner_api/event_handler.h @@ -19,6 +19,10 @@ #include "event_runner.h" #include "dumper.h" +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + namespace OHOS { namespace AppExecFwk { enum class EventType { @@ -28,15 +32,21 @@ enum class EventType { }; struct Caller { - std::string file_; - int line_; - std::string func_; - + std::string file_ {""}; + int line_ {0}; + std::string func_ {""}; +#if __has_builtin(__builtin_FILE) Caller(std::string file = __builtin_FILE(), int line = __builtin_LINE(), std::string func = __builtin_FUNCTION()): file_(file), line_(line), func_(func) { } - +#else + Caller() { + } +#endif std::string ToString() { + if (file_.empty()) { + return "[ ]"; + } size_t split = file_.find_last_of("/\\"); if (split == std::string::npos) { split = 0;