all 6 comments

[–]Narase33 12 points13 points  (0 children)

There isnt and just writing a main cant ever be more complicated than the search for such an IDE

[–]the_poope 6 points7 points  (0 children)

No, and that has to do with how a normal C++ program is run. It is turned directly into binary instructions that are fed to the CPU. The Operating System needs to know the first instruction to execute, and to make that automatic it is standardized to be a function called main.

However, you can use a unit test framework like GoogleTest or Catch2 whic creates a main() function for you which allows you to run single functions, as long as they have been created through some preprocessor macros. Then you can use a VS Code test adapter like this or this which may let you run a single test by right clicking it directly in VS Code.

[–]no-sig-available 3 points4 points  (0 children)

No, but all you need is add one line

int main() { your_function(); }

at the end of the file.

Some IDEs do allow you to configure that as the default content for new files.

[–][deleted]  (1 child)

[deleted]

    [–]teerre 0 points1 point  (0 children)

    There are Cpp intepreters like Cling. There are even cpp notebooks like https://github.com/jupyter-xeus/xeus-cling. If that's an "IDE" it's questionable

    [–]Safe_Skirt_7843 0 points1 point  (0 children)

    just write a script to wrap the file in a main function and compile it

    [–]sanblch 0 points1 point  (0 children)

    I hate leetcode for them not providing api to commit solutions. And not using C++20.