codeict's blog

By codeict, history, 3 years ago, In English

I was unable to find a simple yet powerful CP setup for my needs, so I decided to create one myself. I hope someone will find this useful.

This setup uses C++ in VSCode with debugging support for users in Windows and Ubuntu.

Features

  1. VSCode ready to use out of the box (Only windows users need to correct MinGW installation path).
  2. Run .\windows-reset.bat in Windows or ./ubuntu-reset.sh in Ubuntu to reset the Current Folder.
  3. All .cpp files automatically take input from input.txt and output to output.txt in the same folder. No need for complicated ifdefs.
  4. Leverage powerful features of VSCode:
    • Step Through Debugging (Execute the code line by line, Hover over variables to get values)
    • Debug Console (View any object i.e. map, set, vector or any complex object)
    • Zen Mode (Utilize your screen to the fullest)

Please feel free to post Issues/Suggestions at the Github Repository.

Github Repository

Installation video for Windows on Youtube

Installation video for Ubuntu on Youtube

VSCode setup Screenshot

  • Vote: I like it
  • +45
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it +5 Vote: I do not like it

This is nice, thank you for sharing it!

I suggest having a non-debug mode, so as to enable compiler optimizations.

  • »
    »
    3 years ago, # ^ |
    Rev. 3   Vote: I like it +17 Vote: I do not like it

    Great to see your interest in this!

    Sure, this can be done. Can you please answer:

    1. Is there any other benefit to this apart from faster execution while testing.
    2. Are these all the parameters you would look for: -Wshadow, -Wall, -O2, -Wno-unused-result
    • »
      »
      »
      3 years ago, # ^ |
      Rev. 2   Vote: I like it +5 Vote: I do not like it
      1. Nothing else I can see.
      2. I would add -std=c++17, -march=native, -fsanitize=signed-integer-overflow,undefined. Those can be added in the debug mode too.

      Btw, it'll be nice if you also explain how to change some of the settings, like adding a compiler flag and playing with these JSON files, so that one can override some settings if he needs to.

      • »
        »
        »
        »
        3 years ago, # ^ |
          Vote: I like it +14 Vote: I do not like it

        I have added the compilation arguments here. Some of them were failing in Windows and have been commented for Windows only.

        Regarding an Optimized Build, the best that VSCode can support currently is to ask the user everytime for which build to run.. i.e debug or optimised. This will be a nuisance (and actually take more time than its saving). I will wait till this issue in VSCode is resolved. Then maybe you can press F5 for debugging and F6 for optimized..

        About configuring VSCode JSON Files, here is the official (and best) documentation.

        Let me know if you have any other suggestions :)

»
3 years ago, # |
  Vote: I like it +15 Vote: I do not like it

Did you try acmX extention on vscode? It parses contests, makes input generator, stress tests the solution and more.

  • »
    »
    3 years ago, # ^ |
    Rev. 2   Vote: I like it +9 Vote: I do not like it

    Yes, that is a great extension. I did come across it while searching for a setup.

    In my understanding it serves a different purpose though. It kicks in after you have created your code locally and automates the test-checking and submission process. You should still be able to use it on top of this setup.

    My purpose here is to allow writing and debugging c++ code locally without having to setup VS Code.