Say, I have 2 files:
I compile the mainprogram.cpp normally.
Then, when i execute mainprogram.exe, I want it to compile the other file, secondaryprogram.cpp as if from the command line.
I can compile with g++ -o mainprogram E:\mainprogram.cpp
So naturally I tried this:
If your target is Windows, you could try out the "ExecuteShell" function to call your compiler. but why you need to compile another program? if your "mainprogram"'s only purpose is handling your project, you should use a .bat script (or a .sh on Linux) instead.
There are several ways of doing that, but I don't recommend it as it influence with high complexity within the code. High complexity might lead your code to suffer from bugs and errors that are hard to be detected later. There programs that might help doing it, like checkmarx but it's recommended to try and avoid this kind of situations.
@Benhart So what would be a better alternative?
@barnack could you please exemplify how I would do that? I would make a bat script and call it using a ExecuteShell or system from withibg an actual c++ program ^^? I want this to be done from a c++ program.
Ps I updated the question