diff --git a/ide/vs2017/mimalloc-override.vcxproj b/ide/vs2017/mimalloc-override.vcxproj
index 3ca8158a..f41b2efc 100644
--- a/ide/vs2017/mimalloc-override.vcxproj
+++ b/ide/vs2017/mimalloc-override.vcxproj
@@ -100,7 +100,7 @@
MI_SHARED_LIB;MI_SHARED_LIB_EXPORT;MI_MALLOC_OVERRIDE;%(PreprocessorDefinitions);MultiThreadedDebugDLLfalse
- Default
+ CompileAsCpp../../bin/mimalloc-redirect32.lib;%(AdditionalDependencies)
@@ -121,7 +121,7 @@
MI_SHARED_LIB;MI_SHARED_LIB_EXPORT;MI_MALLOC_OVERRIDE;%(PreprocessorDefinitions);MultiThreadedDebugDLLfalse
- Default
+ CompileAsCpp../../bin/mimalloc-redirect.lib;%(AdditionalDependencies)
@@ -152,7 +152,7 @@
$(IntDir)falseMultiThreadedDLL
- Default
+ CompileAsCpptrue
@@ -177,7 +177,7 @@
$(IntDir)falseMultiThreadedDLL
- Default
+ CompileAsCpptrue
diff --git a/ide/vs2017/mimalloc.vcxproj b/ide/vs2017/mimalloc.vcxproj
index a8cb7566..3e453471 100644
--- a/ide/vs2017/mimalloc.vcxproj
+++ b/ide/vs2017/mimalloc.vcxproj
@@ -154,7 +154,7 @@
Neitherfalsefalse
- Default
+ CompileAsCpptrue
@@ -185,7 +185,7 @@
Neitherfalsefalse
- Default
+ CompileAsCpptrue
diff --git a/include/mimalloc-override.h b/include/mimalloc-override.h
index c3348068..56b41e6b 100644
--- a/include/mimalloc-override.h
+++ b/include/mimalloc-override.h
@@ -12,7 +12,7 @@ terms of the MIT license. A copy of the license can be found in the file
This header can be used to statically redirect malloc/free and new/delete
to the mimalloc variants. This can be useful if one can include this file on
each source file in a project (but be careful when using external code to
-not accidentally mix pointer from different allocators).
+not accidentally mix pointers from different allocators).
On windows it can still be good to always try to include this header even
when dynamically overriding since this will give better performance especially
diff --git a/src/init.c b/src/init.c
index d00d7c05..152e906b 100644
--- a/src/init.c
+++ b/src/init.c
@@ -384,12 +384,18 @@ bool _mi_preloading() {
// Communicate with the redirection module on Windows
#if defined(_WIN32) && defined(MI_SHARED_LIB)
+#ifdef __cplusplus
+extern "C" {
+#endif
mi_decl_export void _mi_redirect_init() {
// called on redirection
mi_redirected = true;
}
__declspec(dllimport) bool mi_allocator_init(const char** message);
__declspec(dllimport) void mi_allocator_done();
+#ifdef __cplusplus
+}
+#endif
#else
static bool mi_allocator_init(const char** message) {
if (message != NULL) *message = NULL;
diff --git a/test/main-override.cpp b/test/main-override.cpp
index fb7ab7a1..6c7fc0d5 100644
--- a/test/main-override.cpp
+++ b/test/main-override.cpp
@@ -23,14 +23,14 @@ public:
int main() {
- mi_version();
+ mi_stats_reset(); // ignore earlier allocations
atexit(free_p);
void* p1 = malloc(78);
void* p2 = mi_malloc_aligned(16,24);
free(p1);
p1 = malloc(8);
char* s = mi_strdup("hello\n");
- mi_free(p2);
+ free(p2);
p2 = malloc(16);
p1 = realloc(p1, 32);
free(p1);
@@ -39,7 +39,7 @@ int main() {
Test* t = new Test(42);
delete t;
t = new (std::nothrow) Test(42);
- delete t;
+ delete t;
return 0;
}