diff options
author | Jeremy Kniager <jeremyk@lunarg.com> | 2019-06-17 14:04:38 -0600 |
---|---|---|
committer | jeremyk-lunarg <jeremyk@lunarg.com> | 2019-06-20 09:47:51 -0600 |
commit | 7a5656a4aefdc3af698cdc8f5e2fc55b7743fa5d (patch) | |
tree | baf4bfbf75a712673dbc918535c4f4d71cf909de | |
parent | 35a7de8396de09fea82f8dd663d3a2087c6b7f0b (diff) | |
download | vulkan-tools-7a5656a4aefdc3af698cdc8f5e2fc55b7743fa5d.tar.gz |
vulkaninfo: Fix issue 202
Vulkaninfo was replacing function `snprintf`
with function `_snprintf` on windows.
This seems to be for backwards compatiblity
with VS2013.
`_snprintf` is considered deprecated in VS2015
as `snprintf` is properly implemented.
Since we are dropping compatibility with VS2013 it
seems like this replacement should be removed.
Due to AppVeyor failing to build when this pre-processor
command is removed entirely, the command has been modified
to replace `snprintf` with `_snprintf_s`.
This command should hopefully be removed entirely in a future
commit.
Change-Id: I85f726fcb0a1cfcc902487100d35dc63d2ba00d8
-rw-r--r-- | vulkaninfo/vulkaninfo.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/vulkaninfo/vulkaninfo.c b/vulkaninfo/vulkaninfo.c index 888055be..e96df728 100644 --- a/vulkaninfo/vulkaninfo.c +++ b/vulkaninfo/vulkaninfo.c @@ -58,7 +58,6 @@ #ifdef _WIN32 -#define snprintf _snprintf #define strdup _strdup // Returns nonzero if the console is used only for this process. Will return @@ -4950,7 +4949,11 @@ static char *HumanReadable(const size_t sz) { if (which >= 0) { unit[0] = prefixes[which]; } +#ifdef _WIN32 + _snprintf_s(buf, kBufferSize * sizeof(char), kBufferSize, "%.2f %sB", result, unit); +#else snprintf(buf, kBufferSize, "%.2f %sB", result, unit); +#endif return strndup(buf, kBufferSize); } @@ -5561,7 +5564,11 @@ int main(int argc, char **argv) { AppCreateInstance(&inst); if (html_output) { +#ifdef _WIN32 + if (fopen_s(&out, "vulkaninfo.html", "w") != 0) out = NULL; +#else out = fopen("vulkaninfo.html", "w"); +#endif if (!out) { printf("Unable to open vulkaninfo.html for writing\n"); return 1; @@ -5648,8 +5655,13 @@ int main(int argc, char **argv) { VkLayerProperties const *layer_prop = &inst.global_layers[i].layer_properties; ExtractVersion(layer_prop->specVersion, &layer_major, &layer_minor, &layer_patch); +#ifdef _WIN32 + _snprintf_s(spec_version, sizeof(spec_version), 64, "%d.%d.%d", layer_major, layer_minor, layer_patch); + _snprintf_s(layer_version, sizeof(layer_version), 64, "%d", layer_prop->implementationVersion); +#else snprintf(spec_version, sizeof(spec_version), "%d.%d.%d", layer_major, layer_minor, layer_patch); snprintf(layer_version, sizeof(layer_version), "%d", layer_prop->implementationVersion); +#endif if (html_output) { fprintf(out, "\t\t\t\t<details><summary>"); |