C++ Win32 without C Runtime library dependency but with malloc, free atd
Domanda
I want to reduce size of my win32 applications programmed in MS Visual Studio C++ and I also want to have guaranteed compatibility on all Windows version (XP and upper without Visual C++ Redistributable Package). I used /MT
and /NODEFAULTLIB
parameter to reduce file size and get rid of C Run-Time library. But I lost access to functions like malloc, free, strcat, strstr, etc... What is the best approach to bypass this problem?
I'm thinking about this alternatives:
- Use LoadLibrary("msvcrt.dll") and GetProcAddress() to dynamic load pointer to this functions from standard windows library
- Program this function by myself for example replace malloc with VirtualAlloc(), free with VirtualFree() etc..
Or is it some other solution for my problem? Thank you
Soluzione
I'll probably never understand why people want to do that (PCs are not exactly embedded platforms with all their size issues), but there's basically three options:
- don't use any standard functions, except for what the compiler offers as intrinsics/builtins
- make your own library
- use some third party library such as http://www.codeproject.com/Articles/15156/Tiny-C-Runtime-Library
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow