summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Böck <markus.boeck02@gmail.com>2024-02-23 12:50:20 +0100
committerMarkus Böck <markus.boeck02@gmail.com>2024-02-23 12:50:33 +0100
commitd9e4309b451c1b24d4e0a6304057663b877e5266 (patch)
tree3b6e706b2c4cfe7eb85d06c02cceed36611016c2
parent3dfca24dda1b3596685d02109185ea2885cc0124 (diff)
[mlir][NFC] Fix format specifier warning on Windows
`%ld` specifier is defined to work on values of type `long`. The parameter given to `fprintf` is of type `intptr_t` whose actual underlying integer type is unspecified. On Unix systems it happens to commonly be `long` but on 64-bit Windows it is defined as `long long`. The cross-platform way to print a `intptr_t` is to use `PRIdPTR` which expands to the correct format specifier for `intptr_t`. This avoids any undefined behaviour and compiler warnings.
-rw-r--r--mlir/test/CAPI/llvm.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mlir/test/CAPI/llvm.c b/mlir/test/CAPI/llvm.c
index 5a78fac91a50..1817988dd67d 100644
--- a/mlir/test/CAPI/llvm.c
+++ b/mlir/test/CAPI/llvm.c
@@ -15,6 +15,7 @@
#include "mlir-c/Support.h"
#include <assert.h>
+#include <inttypes.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@@ -105,7 +106,7 @@ static int testStructTypeCreation(MlirContext ctx) {
// CHECK: i8
// CHECK: i32
// CHECK: i64
- fprintf(stderr, "num elements: %ld\n",
+ fprintf(stderr, "num elements: %" PRIdPTR "\n",
mlirLLVMStructTypeGetNumElementTypes(literal));
for (intptr_t i = 0; i < 3; ++i) {
mlirTypeDump(mlirLLVMStructTypeGetElementType(literal, i));