Fix namespace issues in mkxp-polyfill.h

This commit is contained in:
刘皓 2025-07-30 17:30:10 -04:00
parent c52918eca1
commit 917c3d735f
No known key found for this signature in database
GPG key ID: 7901753DB465B711

View file

@ -288,7 +288,7 @@ namespace std {
inline int sprintf(char *buffer, const char *format, ...) { inline int sprintf(char *buffer, const char *format, ...) {
va_list vlist; va_list vlist;
va_start(vlist, format); va_start(vlist, format);
int result = vsprintf(buffer, buf_size, format, vlist); int result = ::vsprintf(buffer, buf_size, format, vlist);
va_end(vlist); va_end(vlist);
return result; return result;
} }
@ -300,7 +300,7 @@ namespace std {
inline int snprintf(char *buffer, size_t buf_size, const char *format, ...) { inline int snprintf(char *buffer, size_t buf_size, const char *format, ...) {
va_list vlist; va_list vlist;
va_start(vlist, format); va_start(vlist, format);
int result = vsnprintf(buffer, buf_size, format, vlist); int result = ::vsnprintf(buffer, buf_size, format, vlist);
va_end(vlist); va_end(vlist);
return result; return result;
} }
@ -310,7 +310,7 @@ namespace std {
# ifdef MKXPZ_NO_STD_VSPRINTF # ifdef MKXPZ_NO_STD_VSPRINTF
namespace std { namespace std {
inline int vsprintf(char *buffer, const char *format, va_list vlist) { inline int vsprintf(char *buffer, const char *format, va_list vlist) {
return vsprintf(buffer, buf_size, format, vlist); return ::vsprintf(buffer, buf_size, format, vlist);
} }
} }
# endif # endif
@ -318,7 +318,7 @@ namespace std {
# ifdef MKXPZ_NO_STD_VSNPRINTF # ifdef MKXPZ_NO_STD_VSNPRINTF
namespace std { namespace std {
inline int vsnprintf(char *buffer, size_t buf_size, const char *format, va_list vlist) { inline int vsnprintf(char *buffer, size_t buf_size, const char *format, va_list vlist) {
return vsnprintf(buffer, buf_size, format, vlist); return ::vsnprintf(buffer, buf_size, format, vlist);
} }
} }
# endif # endif
@ -326,15 +326,15 @@ namespace std {
# ifdef MKXPZ_NO_STD_ROUND # ifdef MKXPZ_NO_STD_ROUND
namespace std { namespace std {
inline constexpr float round(float x) { inline constexpr float round(float x) {
return roundf(x); return ::roundf(x);
} }
inline constexpr double round(double x) { inline constexpr double round(double x) {
return round(x); return ::round(x);
} }
inline constexpr long double round(long double x) { inline constexpr long double round(long double x) {
return roundl(x); return ::roundl(x);
} }
} }
# endif # endif
@ -342,15 +342,15 @@ namespace std {
# ifdef MKXPZ_NO_STD_LROUND # ifdef MKXPZ_NO_STD_LROUND
namespace std { namespace std {
inline constexpr long lround(float x) { inline constexpr long lround(float x) {
return lroundf(x); return ::lroundf(x);
} }
inline constexpr long lround(double x) { inline constexpr long lround(double x) {
return lround(x); return ::lround(x);
} }
inline constexpr long lround(long double x) { inline constexpr long lround(long double x) {
return lroundl(x); return ::lroundl(x);
} }
} }
# endif # endif
@ -358,15 +358,15 @@ namespace std {
# ifdef MKXPZ_NO_STD_COPYSIGN # ifdef MKXPZ_NO_STD_COPYSIGN
namespace std { namespace std {
inline constexpr float copysign(float x, float y) { inline constexpr float copysign(float x, float y) {
return copysignf(x, y); return ::copysignf(x, y);
} }
inline constexpr double copysign(double x, double y) { inline constexpr double copysign(double x, double y) {
return copysign(x, y); return ::copysign(x, y);
} }
inline constexpr long double copysign(long double x, long double y) { inline constexpr long double copysign(long double x, long double y) {
return copysignl(x, y); return ::copysignl(x, y);
} }
} }
# endif # endif
@ -374,15 +374,15 @@ namespace std {
# ifdef MKXPZ_NO_STD_CBRT # ifdef MKXPZ_NO_STD_CBRT
namespace std { namespace std {
inline constexpr float cbrt(float x) { inline constexpr float cbrt(float x) {
return cbrtf(x); return ::cbrtf(x);
} }
inline constexpr double cbrt(double x) { inline constexpr double cbrt(double x) {
return cbrt(x); return ::cbrt(x);
} }
inline constexpr long double cbrt(long double x) { inline constexpr long double cbrt(long double x) {
return cbrtl(x); return ::cbrtl(x);
} }
} }
# endif # endif
@ -390,62 +390,62 @@ namespace std {
# ifdef MKXPZ_NO_STD_LOG2 # ifdef MKXPZ_NO_STD_LOG2
namespace std { namespace std {
inline constexpr float log2(float x) { inline constexpr float log2(float x) {
return log2f(x); return ::log2f(x);
} }
inline constexpr double log2(double x) { inline constexpr double log2(double x) {
return log2(x); return ::log2(x);
} }
} }
# endif # endif
# ifdef MKXPZ_NO_STD_TO_STRING # ifdef MKXPZ_NO_STD_TO_STRING
namespace std { namespace std {
inline std::string to_string(int x) { inline string to_string(int x) {
std::array<char, 22> array; array<char, 22> array;
std::sprintf(array.data(), "%d", x); sprintf(array.data(), "%d", x);
return array.data(); return array.data();
} }
inline std::string to_string(long x) { inline string to_string(long x) {
std::array<char, 22> array; array<char, 22> array;
std::sprintf(array.data(), "%ld", x); sprintf(array.data(), "%ld", x);
return array.data(); return array.data();
} }
inline std::string to_string(long long x) { inline string to_string(long long x) {
std::array<char, 22> array; array<char, 22> array;
std::sprintf(array.data(), "%lld", x); sprintf(array.data(), "%lld", x);
return array.data(); return array.data();
} }
inline std::string to_string(unsigned int x) { inline string to_string(unsigned int x) {
std::array<char, 22> array; array<char, 22> array;
std::sprintf(array.data(), "%u", x); sprintf(array.data(), "%u", x);
return array.data(); return array.data();
} }
inline std::string to_string(unsigned long x) { inline string to_string(unsigned long x) {
std::array<char, 22> array; array<char, 22> array;
std::sprintf(array.data(), "%lu", x); sprintf(array.data(), "%lu", x);
return array.data(); return array.data();
} }
inline std::string to_string(unsigned long long x) { inline string to_string(unsigned long long x) {
std::array<char, 22> array; array<char, 22> array;
std::sprintf(array.data(), "%llu", x); sprintf(array.data(), "%llu", x);
return array.data(); return array.data();
} }
inline std::string to_string(float x) { inline string to_string(float x) {
std::array<char, 256> array; array<char, 256> array;
std::sprintf(array.data(), "%f", x); sprintf(array.data(), "%f", x);
return array.data(); return array.data();
} }
inline std::string to_string(double x) { inline string to_string(double x) {
std::array<char, 256> array; array<char, 256> array;
std::sprintf(array.data(), "%f", x); sprintf(array.data(), "%f", x);
return array.data(); return array.data();
} }
} }
@ -453,9 +453,9 @@ namespace std {
# ifdef MKXPZ_NO_STD_STOI # ifdef MKXPZ_NO_STD_STOI
namespace std { namespace std {
inline int stoi(const std::string &str, size_t *pos = nullptr, int base = 10) { inline int stoi(const string &str, size_t *pos = nullptr, int base = 10) {
char *ptr; char *ptr;
int result = (int)strtol(str.c_str(), &ptr, base); int result = (int)::strtol(str.c_str(), &ptr, base);
if (pos != nullptr) { if (pos != nullptr) {
*pos = ptr - str.c_str(); *pos = ptr - str.c_str();
} }
@ -466,9 +466,9 @@ namespace std {
# ifdef MKXPZ_NO_STD_STOL # ifdef MKXPZ_NO_STD_STOL
namespace std { namespace std {
inline long stol(const std::string &str, size_t *pos = nullptr, int base = 10) { inline long stol(const string &str, size_t *pos = nullptr, int base = 10) {
char *ptr; char *ptr;
long result = strtol(str.c_str(), &ptr, base); long result = ::strtol(str.c_str(), &ptr, base);
if (pos != nullptr) { if (pos != nullptr) {
*pos = ptr - str.c_str(); *pos = ptr - str.c_str();
} }
@ -479,9 +479,9 @@ namespace std {
# ifdef MKXPZ_NO_STD_STOLL # ifdef MKXPZ_NO_STD_STOLL
namespace std { namespace std {
inline long long stoll(const std::string &str, size_t *pos = nullptr, int base = 10) { inline long long stoll(const string &str, size_t *pos = nullptr, int base = 10) {
char *ptr; char *ptr;
long long result = strtoll(str.c_str(), &ptr, base); long long result = ::strtoll(str.c_str(), &ptr, base);
if (pos != nullptr) { if (pos != nullptr) {
*pos = ptr - str.c_str(); *pos = ptr - str.c_str();
} }
@ -492,9 +492,9 @@ namespace std {
# ifdef MKXPZ_NO_STD_STOUL # ifdef MKXPZ_NO_STD_STOUL
namespace std { namespace std {
inline unsigned long stoul(const std::string &str, size_t *pos = nullptr, int base = 10) { inline unsigned long stoul(const string &str, size_t *pos = nullptr, int base = 10) {
char *ptr; char *ptr;
unsigned long result = strtoul(str.c_str(), &ptr, base); unsigned long result = ::strtoul(str.c_str(), &ptr, base);
if (pos != nullptr) { if (pos != nullptr) {
*pos = ptr - str.c_str(); *pos = ptr - str.c_str();
} }
@ -505,9 +505,9 @@ namespace std {
# ifdef MKXPZ_NO_STD_STOULL # ifdef MKXPZ_NO_STD_STOULL
namespace std { namespace std {
inline unsigned long long stoull(const std::string &str, size_t *pos = nullptr, int base = 10) { inline unsigned long long stoull(const string &str, size_t *pos = nullptr, int base = 10) {
char *ptr; char *ptr;
unsigned long long result = strtoull(str.c_str(), &ptr, base); unsigned long long result = ::strtoull(str.c_str(), &ptr, base);
if (pos != nullptr) { if (pos != nullptr) {
*pos = ptr - str.c_str(); *pos = ptr - str.c_str();
} }
@ -518,9 +518,9 @@ namespace std {
# ifdef MKXPZ_NO_STD_STOF # ifdef MKXPZ_NO_STD_STOF
namespace std { namespace std {
inline float stof(const std::string &str, size_t *pos = nullptr) { inline float stof(const string &str, size_t *pos = nullptr) {
char *ptr; char *ptr;
float result = strtof(str.c_str(), &ptr); float result = ::strtof(str.c_str(), &ptr);
if (pos != nullptr) { if (pos != nullptr) {
*pos = ptr - str.c_str(); *pos = ptr - str.c_str();
} }
@ -531,9 +531,9 @@ namespace std {
# ifdef MKXPZ_NO_STD_STOD # ifdef MKXPZ_NO_STD_STOD
namespace std { namespace std {
inline double stod(const std::string &str, size_t *pos = nullptr) { inline double stod(const string &str, size_t *pos = nullptr) {
char *ptr; char *ptr;
double result = strtod(str.c_str(), &ptr); double result = ::strtod(str.c_str(), &ptr);
if (pos != nullptr) { if (pos != nullptr) {
*pos = ptr - str.c_str(); *pos = ptr - str.c_str();
} }
@ -544,9 +544,9 @@ namespace std {
# ifdef MKXPZ_NO_STD_STOLD # ifdef MKXPZ_NO_STD_STOLD
namespace std { namespace std {
inline long double stold(const std::string &str, size_t *pos = nullptr) { inline long double stold(const string &str, size_t *pos = nullptr) {
char *ptr; char *ptr;
long double result = strtold(str.c_str(), &ptr); long double result = ::strtold(str.c_str(), &ptr);
if (pos != nullptr) { if (pos != nullptr) {
*pos = ptr - str.c_str(); *pos = ptr - str.c_str();
} }