unneon / icie

Competitive programming IDE-as-a-VS-Code-plugin
https://marketplace.visualstudio.com/items?itemName=pustaczek.icie
Mozilla Public License 2.0
84 stars 11 forks source link

Allow configuration of flags for debug and release builds #10

Closed mikaelmello closed 5 years ago

mikaelmello commented 5 years ago

I like to set the -DDEBUG flag because of this macro:

#ifdef DEBUG
#define debug(x) cout << #x << " = " << x << endl
#else
#define debug(x)
#endif

This way, I can easily debug my code and send the solution without having to remove the debug calls. However, ICIE does not let me submit because, for him, the tests have failed.

I'm not sure if ICIE already uses release builds in order to test the submission (when submitting), but if it does, it would be cool to use different flags.

unneon commented 5 years ago

What you want to do instead is use cerr instead of cout for logging. It writes values to a different stream which icie can tell apart, so you can have both automated tests and debug messages :)

Clarification about debug/release: all tests run in debug mode so that sanitizer and -D_GLIBCXX_DEBUG can catch bugs(when using exactly-sized std::vector it really is a miracle worker). Release mode is only used in Discover (to speed up slow solutions and test generators) and when selected in manual builds.

Though adding specific flags for each profile is something I wanted to add anyway, as it only really requires adding two new config entries and an if.

mikaelmello commented 5 years ago

What you want to do instead is use cerr instead of cout for logging. It writes values to a different stream which icie can tell apart, so you can have both automated tests and debug messages :)

That is a much better idea, thanks! And it does even work with Codeforces, no more need for #ifdef then

unneon commented 5 years ago

An ifdef is still necessary - writing to any stream is rather slow and can easily give you TLE if you happen to log too much.