diff --git a/src/Cafe/OS/common/OSUtil.h b/src/Cafe/OS/common/OSUtil.h index 6801f6af..84e38a6c 100644 --- a/src/Cafe/OS/common/OSUtil.h +++ b/src/Cafe/OS/common/OSUtil.h @@ -140,6 +140,17 @@ static std::tuple cafeExportBuildArgTuple(PPCInterpreter_t* hCPU, R(fn) return std::tuple{ cafeExportGetParamWrapper(hCPU, gprIndex, fprIndex)... }; } +template +T cafeExportGetFormatParamWrapper(PPCInterpreter_t* hCPU, int& gprIndex, int& fprIndex) +{ + T v; + cafeExportParamWrapper::getParamWrapper(hCPU, gprIndex, fprIndex, v); + // if T is char* or const char*, return "null" instead of nullptr since newer fmtlib would throw otherwise + if constexpr (std::is_same_v || std::is_same_v) + return v ? v : (T)"null"; + return v; +} + template using _CAFE_FORMAT_ARG = std::conditional_t, std::conditional_t || std::is_same_v, T, MEMPTR>, T>; @@ -150,7 +161,7 @@ static auto cafeExportBuildFormatTuple(PPCInterpreter_t* hCPU, R(fn)(Args...)) int gprIndex = 0; int fprIndex = 0; return std::tuple<_CAFE_FORMAT_ARG...>{ - cafeExportGetParamWrapper<_CAFE_FORMAT_ARG>(hCPU, gprIndex, fprIndex)... + cafeExportGetFormatParamWrapper<_CAFE_FORMAT_ARG>(hCPU, gprIndex, fprIndex)... }; }