ensure C++ compilation on windows
This commit is contained in:
parent
598ed19c61
commit
66b8c37ab3
@ -100,7 +100,7 @@
|
|||||||
<PreprocessorDefinitions>MI_SHARED_LIB;MI_SHARED_LIB_EXPORT;MI_MALLOC_OVERRIDE;%(PreprocessorDefinitions);</PreprocessorDefinitions>
|
<PreprocessorDefinitions>MI_SHARED_LIB;MI_SHARED_LIB_EXPORT;MI_MALLOC_OVERRIDE;%(PreprocessorDefinitions);</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<CompileAs>Default</CompileAs>
|
<CompileAs>CompileAsCpp</CompileAs>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>../../bin/mimalloc-redirect32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>../../bin/mimalloc-redirect32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
@ -121,7 +121,7 @@
|
|||||||
<PreprocessorDefinitions>MI_SHARED_LIB;MI_SHARED_LIB_EXPORT;MI_MALLOC_OVERRIDE;%(PreprocessorDefinitions);</PreprocessorDefinitions>
|
<PreprocessorDefinitions>MI_SHARED_LIB;MI_SHARED_LIB_EXPORT;MI_MALLOC_OVERRIDE;%(PreprocessorDefinitions);</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<CompileAs>Default</CompileAs>
|
<CompileAs>CompileAsCpp</CompileAs>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>../../bin/mimalloc-redirect.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>../../bin/mimalloc-redirect.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
@ -152,7 +152,7 @@
|
|||||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<CompileAs>Default</CompileAs>
|
<CompileAs>CompileAsCpp</CompileAs>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
@ -177,7 +177,7 @@
|
|||||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<CompileAs>Default</CompileAs>
|
<CompileAs>CompileAsCpp</CompileAs>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
@ -154,7 +154,7 @@
|
|||||||
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
|
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
|
||||||
<OmitFramePointers>false</OmitFramePointers>
|
<OmitFramePointers>false</OmitFramePointers>
|
||||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||||
<CompileAs>Default</CompileAs>
|
<CompileAs>CompileAsCpp</CompileAs>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
@ -185,7 +185,7 @@
|
|||||||
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
|
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
|
||||||
<OmitFramePointers>false</OmitFramePointers>
|
<OmitFramePointers>false</OmitFramePointers>
|
||||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||||
<CompileAs>Default</CompileAs>
|
<CompileAs>CompileAsCpp</CompileAs>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
@ -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
|
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
|
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
|
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
|
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
|
when dynamically overriding since this will give better performance especially
|
||||||
|
@ -384,12 +384,18 @@ bool _mi_preloading() {
|
|||||||
|
|
||||||
// Communicate with the redirection module on Windows
|
// Communicate with the redirection module on Windows
|
||||||
#if defined(_WIN32) && defined(MI_SHARED_LIB)
|
#if defined(_WIN32) && defined(MI_SHARED_LIB)
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
mi_decl_export void _mi_redirect_init() {
|
mi_decl_export void _mi_redirect_init() {
|
||||||
// called on redirection
|
// called on redirection
|
||||||
mi_redirected = true;
|
mi_redirected = true;
|
||||||
}
|
}
|
||||||
__declspec(dllimport) bool mi_allocator_init(const char** message);
|
__declspec(dllimport) bool mi_allocator_init(const char** message);
|
||||||
__declspec(dllimport) void mi_allocator_done();
|
__declspec(dllimport) void mi_allocator_done();
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
static bool mi_allocator_init(const char** message) {
|
static bool mi_allocator_init(const char** message) {
|
||||||
if (message != NULL) *message = NULL;
|
if (message != NULL) *message = NULL;
|
||||||
|
@ -23,14 +23,14 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
mi_version();
|
mi_stats_reset(); // ignore earlier allocations
|
||||||
atexit(free_p);
|
atexit(free_p);
|
||||||
void* p1 = malloc(78);
|
void* p1 = malloc(78);
|
||||||
void* p2 = mi_malloc_aligned(16,24);
|
void* p2 = mi_malloc_aligned(16,24);
|
||||||
free(p1);
|
free(p1);
|
||||||
p1 = malloc(8);
|
p1 = malloc(8);
|
||||||
char* s = mi_strdup("hello\n");
|
char* s = mi_strdup("hello\n");
|
||||||
mi_free(p2);
|
free(p2);
|
||||||
p2 = malloc(16);
|
p2 = malloc(16);
|
||||||
p1 = realloc(p1, 32);
|
p1 = realloc(p1, 32);
|
||||||
free(p1);
|
free(p1);
|
||||||
|
Loading…
Reference in New Issue
Block a user