Fix Windows build errors.
authorDavid Neto <dneto@google.com>
Wed, 11 Nov 2015 14:44:23 +0000 (09:44 -0500)
committerDavid Neto <dneto@google.com>
Wed, 11 Nov 2015 14:55:51 +0000 (09:55 -0500)
- uint64_t != size_t sometimes
- don't use C99 runtime sized arrays

include/libspirv/libspirv.h
source/disassemble.cpp
test/HexFloat.cpp

index 7112e9d..b61138c 100644 (file)
@@ -480,7 +480,7 @@ void spvTextDestroy(spv_text text);
 /// @param[out] pDiagnostic contains diagnostic on failure
 ///
 /// @return result code
-spv_result_t spvBinaryToText(const uint32_t* binary, const uint64_t wordCount,
+spv_result_t spvBinaryToText(const uint32_t* binary, const size_t wordCount,
                              const uint32_t options,
                              const spv_opcode_table opcodeTable,
                              const spv_operand_table operandTable,
index de720d0..a439b01 100644 (file)
@@ -338,7 +338,7 @@ spv_result_t DisassembleInstruction(
 
 }  // anonymous namespace
 
-spv_result_t spvBinaryToText(const uint32_t* code, const uint64_t wordCount,
+spv_result_t spvBinaryToText(const uint32_t* code, const size_t wordCount,
                              const uint32_t options,
                              const spv_opcode_table opcode_table,
                              const spv_operand_table operand_table,
index 10c5fb7..ee3be89 100644 (file)
@@ -419,17 +419,17 @@ std::string EncodeViaFloatProxy(const T& value) {
 std::string NormalizeExponentInFloatString(std::string in) {
   std::string result;
   // Reserve one spot for the terminating null, even when the sscanf fails.
-  char prefix[in.size() + 1];
+  std::vector<char> prefix(in.size()+1);
   char e;
   char plus_or_minus;
   int exponent;  // in base 10
-  if ((4 == std::sscanf(in.c_str(), "%[-+.0123456789]%c%c%d", prefix, &e,
+  if ((4 == std::sscanf(in.c_str(), "%[-+.0123456789]%c%c%d", prefix.data(), &e,
                         &plus_or_minus, &exponent)) &&
       (e == 'e' || e == 'E') &&
       (plus_or_minus == '-' || plus_or_minus == '+')) {
     // It looks like a floating point value with exponent.
     std::stringstream out;
-    out << prefix << 'e' << plus_or_minus << exponent;
+    out << prefix.data() << 'e' << plus_or_minus << exponent;
     result = out.str();
   } else {
     result = in;