I'm afraid that what you are trying to do is not possible. The problem is not with the fact that you are not able to compile your project using the built-in compiler. The problem is that you are trying to use STL in real-time code.
In real-time code, there is a requirement to always finish a single time step on time, before the next one is due to start. This in effect requires time-deterministic behavior of the real-time code, i.e. more or less fixed execution time. On the contrary, STL frequently uses features that are not time-deterministic. The most notable examples are dynamic memory allocation and exceptions. While dynamic memory allocation is (with some limitations) supported by the real-time kernel in a real-time deterministic way, exceptions are not. So, it is not possible to use code that can throw exceptions.
This is the reason why most of the STL headers are not available with Real-Time Windows Target - they throw exceptions. You will not be able to run your code by the real-time kernel even if you were able to compile it by another compiler or add STL headers to the built-in compiler somehow. Not to mention the fact that the output binary format of the built-in compiler (which is Clang) and a Microsoft compiler is very different, and only the Clang format is understood and can be loaded by the kernel.
If you are not able to modify your project not to use STL, you still have an option to use Real-Time Windows Target in Normal Mode. For Normal Mode, you can compile your S-function as you normally do for Simulink. Then, you can run yuor model in a way where real-time requirements cannot be enforced, but real-time misses are reported when they happen.
Best Answer