Merge pull request #1966 from fred-wang/macos-snprintf
Fix compilation errors with deprecated sprintf function
This commit is contained in:
commit
e6925974d1
@ -5214,8 +5214,8 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c, bool inside_bloc
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// sprintf warning.
|
||||
// We cannot rely on snprintf existing because, ..., MSVC.
|
||||
// snprintf does not exist or is buggy on older MSVC versions, some of them
|
||||
// being used by MinGW. Use sprintf instead and disable corresponding warning.
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
@ -5275,7 +5275,11 @@ string CompilerGLSL::convert_float_to_string(const SPIRConstant &c, uint32_t col
|
||||
in_type.width = 32;
|
||||
|
||||
char print_buffer[32];
|
||||
#ifdef _WIN32
|
||||
sprintf(print_buffer, "0x%xu", c.scalar(col, row));
|
||||
#else
|
||||
snprintf(print_buffer, sizeof(print_buffer), "0x%xu", c.scalar(col, row));
|
||||
#endif
|
||||
|
||||
const char *comment = "inf";
|
||||
if (float_value == -numeric_limits<float>::infinity())
|
||||
@ -5347,8 +5351,13 @@ std::string CompilerGLSL::convert_double_to_string(const SPIRConstant &c, uint32
|
||||
require_extension_internal("GL_ARB_gpu_shader_int64");
|
||||
|
||||
char print_buffer[64];
|
||||
#ifdef _WIN32
|
||||
sprintf(print_buffer, "0x%llx%s", static_cast<unsigned long long>(u64_value),
|
||||
backend.long_long_literal_suffix ? "ull" : "ul");
|
||||
#else
|
||||
snprintf(print_buffer, sizeof(print_buffer), "0x%llx%s", static_cast<unsigned long long>(u64_value),
|
||||
backend.long_long_literal_suffix ? "ull" : "ul");
|
||||
#endif
|
||||
|
||||
const char *comment = "inf";
|
||||
if (double_value == -numeric_limits<double>::infinity())
|
||||
|
@ -16405,6 +16405,20 @@ void CompilerMSL::emit_block_hints(const SPIRBlock &)
|
||||
string CompilerMSL::additional_fixed_sample_mask_str() const
|
||||
{
|
||||
char print_buffer[32];
|
||||
#ifdef _MSC_VER
|
||||
// snprintf does not exist or is buggy on older MSVC versions, some of
|
||||
// them being used by MinGW. Use sprintf instead and disable
|
||||
// corresponding warning.
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
#if _WIN32
|
||||
sprintf(print_buffer, "0x%x", msl_options.additional_fixed_sample_mask);
|
||||
#else
|
||||
snprintf(print_buffer, sizeof(print_buffer), "0x%x", msl_options.additional_fixed_sample_mask);
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
return print_buffer;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user