There is no reason to use /NODEFAULTLIB`/NODEFAULTLIB
- Use
printfinstead of rolling your solution. But since you are probably removing the standard library. Here you go. writedoes not promise that all bytes will be written. If the kernel buffers are smaller than the number of bytes to be written it will only write a few bytes. You have to address that in yourstdoutFunction.- You might want to create two different definitions for Windows and Linux and then choose which one to use based on a macro, instead of using macros in the same function. It makes the code easier to read. But that is just my style. People may differ.
- When writing parsing code, don't loop over the parse string character by character. Instead, think in terms of tokens.
You can break your problem into tokenizing the format string and doing the correct stuff in a
switchstatement based on the toke. Liketoken, like below. It is much more clear than mixingwchar_tandcharstrings. It also leads to fewer bugs because you are focusing on printing a single in eachcasestatement.