Which Complier?

Started by
14 comments, last by superpig 15 years, 9 months ago
Quote:Original post by EasilyConfused
Well, I'm glad about Code::Blocks. The thing is that if you put an artificial pause at the end of your program, then you happen to want to run the exe from a command line, the pause at the end suddenly becomes really annoying.

And putting your program inside a batch file becomes very difficult as well.

I'm well aware that very few beginners are ever going to do either of these things, which is why I consider system("pause") harmless at that level, but I guess it's good to be aware of the issues.

(Like, what happens if I put a pause.exe that reformats your harddrive in the same directory as your program for example. Woo ha ha ha.)


Ha! most beginners probably don't know what a batch file is!

@Moonshoe: Wow, I had no idea system("pause") was so huge and ugly. So much effort for so small a line...
Advertisement
If you're not debugging and using breakpoints, why not just RUN your app from an open console window?
-- What would Sweetness do?
sorry but
Quote:3. open an operating system shell (relaunches the O/S in a sub-process)
Is the funniest thing I have heard this week. Use system pause if you want just know that it is non portable(which you may or may not care about) and there are other ways that are just as easy.
I don't know how easy this is to do with VS 2008 C++ projects, but in C# projects you can set the program type to a Windows Forms type and the output will be sent to the VS console instead of the standard console. I find this to be more practical than using artifical pauses (like sleep or input) since I don't end up writing code that I'll have to delete later. Though ctrl+F5 seems like the best solution.
Quote:Original post by stonemetal
sorry but
Quote:3. open an operating system shell (relaunches the O/S in a sub-process)
Is the funniest thing I have heard this week. Use system pause if you want just know that it is non portable(which you may or may not care about) and there are other ways that are just as easy.


Yeah...well, I think it was an extremely poorly-worded attempt at saying "OS launches a new process, switches to its context." Otherwise you're entirely correct, seeing as no sane person cares about its relative inefficiency in this case. Of course it's well worth understanding how an OS works, but this is utterly insignificant. system(anything) is pure evil in production code, as it's non-portable and can lead to security holes, but as a development/debugging aid, why not.
There's also the factor that system("PAUSE") simply runs a program called 'pause' - like, pause.exe or something - with absolutely no guarantees as to what that would do. If I wanted to break your program very badly, I could make a copy of FORMAT.COM and drop it in your program's directory renamed to PAUSE.COM...

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

This topic is closed to new replies.

Advertisement