[Mlir-commits] [mlir] 6677815 - [mlir] On Windows, silence warning on functions definition

Alexandre Ganea llvmlistbot at llvm.org
Fri Mar 27 09:24:22 PDT 2020


Author: Alexandre Ganea
Date: 2020-03-27T12:24:12-04:00
New Revision: 667781592a44ed02f42d4a07c85cf1a898543304

URL: https://github.com/llvm/llvm-project/commit/667781592a44ed02f42d4a07c85cf1a898543304
DIFF: https://github.com/llvm/llvm-project/commit/667781592a44ed02f42d4a07c85cf1a898543304.diff

LOG: [mlir] On Windows, silence warning on functions definition

This fixes a number of warnings, where a function is re-defined after it is tagged as "being imported":

D:\llvm-project\mlir\lib\ExecutionEngine\CRunnerUtils.cpp(24,17): warning: 'print_i32' redeclared without 'dllimport' attribute: 'dllexport' attribute added [-Winconsistent-dllimport]
extern "C" void print_i32(int32_t i) { fprintf(stdout, "%" PRId32, i); }
                ^
D:\llvm-project\mlir\include\mlir/ExecutionEngine/CRunnerUtils.h(168,42): note: previous declaration is here
extern "C" MLIR_CRUNNERUTILS_EXPORT void print_i32(int32_t i);
                                         ^

Differential Revision: https://reviews.llvm.org/D76654

Added: 
    

Modified: 
    mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
    mlir/lib/ExecutionEngine/CRunnerUtils.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h b/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
index c1ab7425fec6..020c66e07e85 100644
--- a/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
+++ b/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
@@ -20,6 +20,7 @@
 #ifdef mlir_c_runner_utils_EXPORTS
 /* We are building this library */
 #define MLIR_CRUNNERUTILS_EXPORT __declspec(dllexport)
+#define MLIR_CRUNNERUTILS_DEFINE_FUNCTIONS
 #else
 /* We are using this library */
 #define MLIR_CRUNNERUTILS_EXPORT __declspec(dllimport)
@@ -27,6 +28,7 @@
 #endif // MLIR_CRUNNERUTILS_EXPORT
 #else
 #define MLIR_CRUNNERUTILS_EXPORT
+#define MLIR_CRUNNERUTILS_DEFINE_FUNCTIONS
 #endif // _WIN32
 
 #include <cstdint>

diff  --git a/mlir/lib/ExecutionEngine/CRunnerUtils.cpp b/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
index 7faf3f9d4243..ad5be24378ce 100644
--- a/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
+++ b/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
@@ -17,6 +17,8 @@
 #include <cinttypes>
 #include <cstdio>
 
+#ifdef MLIR_CRUNNERUTILS_DEFINE_FUNCTIONS
+
 // Small runtime support "lib" for vector.print lowering.
 // By providing elementary printing methods only, this
 // library can remain fully unaware of low-level implementation
@@ -29,3 +31,5 @@ extern "C" void print_open() { fputs("( ", stdout); }
 extern "C" void print_close() { fputs(" )", stdout); }
 extern "C" void print_comma() { fputs(", ", stdout); }
 extern "C" void print_newline() { fputc('\n', stdout); }
+
+#endif


        


More information about the Mlir-commits mailing list