FastOlympicCoding icon indicating copy to clipboard operation
FastOlympicCoding copied to clipboard

How to use c++17 in CppFastOlympicCoding package?

Open abmahfuz opened this issue 4 years ago • 21 comments

abmahfuz avatar Sep 26 '20 15:09 abmahfuz

Hi Jatana! I want to use c++17 in cppfastolympiccoding. please help me.

abmahfuz avatar Sep 26 '20 15:09 abmahfuz

Hello! To use C++17, please do the following:

  1. Go to Tools -> [Cpp]FastOlympicCoding -> settings
  2. Copy all settings from the default file (on the left) to the user file (on the right)
  3. Replace all instances of -std=gnu++11 with -std=gnu++17

npanuhin avatar Sep 26 '20 16:09 npanuhin

@npanuhin How can I move the test files to a different directory? I want to change the directory of generating the test files.

j0k4rX avatar May 29 '21 09:05 j0k4rX

@j0k4rX, you can use the tests_relative_dir setting to change the relative path to the directory containing the tests. You can also use the tests_file_suffix setting to change the default :tests suffix for test files (which causes problems on Windows).

For example (FastOlympicCoding.sublime-settings):

"tests_relative_dir": "my_tests",
"tests_file_suffix": ".tests"

will result in: Снимок экрана 2021-05-29 132915

npanuhin avatar May 29 '21 10:05 npanuhin

@npanuhin thanks for the quick reply! But it is not working for me. Still, the file is being saved in the current directory. I am on Linux, using sublime-text 4

j0k4rX avatar May 29 '21 12:05 j0k4rX

Alright, I found out where the problem was: these features were added after 1.4.10 release. Pinging @Jatana to update the package :)

If you do not want to wait, you can use the master branch of this repository:

  1. Remove the package
  2. Package Control: Add Repository -> enter https://github.com/Jatana/FastOlympicCoding
  3. Install the FastOlympicCoding package as usual, but pay attention to the version, it should be v2020.11.13...

Снимок экрана 2021-05-29 152957

npanuhin avatar May 29 '21 12:05 npanuhin

@npanuhin Thank you so much! It worked!

j0k4rX avatar May 29 '21 12:05 j0k4rX

Glad to hear that. You are welcome

npanuhin avatar May 29 '21 12:05 npanuhin

@npanuhin, sorry for disturbing you again. I am stuck at a point. The problem is how to increase stack size for cpp programs in the sublime text? I know these two extra commands to add but don't know how to implement them.

  • for windows : -Wl,--stack,268435456
  • for Linux & mac terminal : ulimit -s unlimited

I got this https://pastebin.com/H9cAHWRR so far. And what does "lint_compile_cmd" does? is this for any error detection?

j0k4rX avatar May 31 '21 13:05 j0k4rX

@npanuhin ??

j0k4rX avatar Jun 03 '21 14:06 j0k4rX

Sorry, I've been a little busy. The config, you provided - doesn't it work? What does it output?

lint_compile_cmd is used for the Lint module of this package (I haven't used it and know nothing about it). I think this is a command to pre-run the program to check it for errors.

npanuhin avatar Jun 03 '21 18:06 npanuhin

@npanuhin, the config that I provided, I don't know whether it is rightly configured or not. you can refer to this https://stackoverflow.com/a/64085509

In codeforces, the stack size allocated for cpp programs is much higher than a machine normally has (you can find the compilation flags here https://codeforces.com/blog/entry/57646), and again Facebook hacker cup also exceeds this memory limit.

I increased stack size in Linux (adding ulimit -s unlimited in bashrc). But it is limited to the shell only, which has nothing to do with sublime text. For windows, it would be easier to update the compilation flag by adding this -Wl,--stack,268435456 code.

j0k4rX avatar Jun 04 '21 10:06 j0k4rX

@j0k4rX If you're not sure where to put the compiler option, it's here https://github.com/Jatana/FastOlympicCoding/blob/3e058e5915ffcb2e5f9fb1673bd34945c46e0940/FastOlympicCoding%20(Linux).sublime-settings#L21

qumusabel avatar Jun 04 '21 15:06 qumusabel

@qumusabel, thanks for the concern! But how can I increase the stack size via that compiler option? see https://github.com/Jatana/FastOlympicCoding/issues/21#issuecomment-851488563 How to implement them?

j0k4rX avatar Jun 04 '21 16:06 j0k4rX

Actually, FOC will run the program in a shell: https://github.com/Jatana/FastOlympicCoding/blob/3e058e5915ffcb2e5f9fb1673bd34945c46e0940/Modules/ProcessManager.py#L74-L75 So you just have to add ulimit -s unlimited; at the beginning of run_cmd:

"run_cmd": "ulimit -s unlimited; ./\"{file_name}\" {args} -debug"

qumusabel avatar Jun 04 '21 17:06 qumusabel

Actually, FOC will run the program in a shell:

https://github.com/Jatana/FastOlympicCoding/blob/3e058e5915ffcb2e5f9fb1673bd34945c46e0940/Modules/ProcessManager.py#L74-L75

So you just have to add ulimit -s unlimited; at the beginning of run_cmd:

"run_cmd": "ulimit -s unlimited; ./\"{file_name}\" {args} -debug"

I think the appropriate would be adding ulimit -s unlimited in compile_cmd. Can you please check?

j0k4rX avatar Jun 05 '21 13:06 j0k4rX

The compiler and linker are not responsible for stack allocation. It's a setting for current shell, so it must be added to run_cmd.

qumusabel avatar Jun 05 '21 13:06 qumusabel

Is the issue resolved?

qumusabel avatar Jun 06 '21 11:06 qumusabel

Is the issue resolved?

can u pls explain how the class-completions work here? i think, the modules section & olympic_funcs.py maintain those, right?

j0k4rX avatar Jun 28 '22 09:06 j0k4rX

Actually, FOC will run the program in a shell:

https://github.com/Jatana/FastOlympicCoding/blob/3e058e5915ffcb2e5f9fb1673bd34945c46e0940/Modules/ProcessManager.py#L74-L75

So you just have to add ulimit -s unlimited; at the beginning of run_cmd:

"run_cmd": "ulimit -s unlimited; ./\"{file_name}\" {args} -debug"

And in windows? should i allocate stack in compile time?

DeveloperKev avatar Nov 10 '22 12:11 DeveloperKev

Actually, FOC will run the program in a shell:

https://github.com/Jatana/FastOlympicCoding/blob/3e058e5915ffcb2e5f9fb1673bd34945c46e0940/Modules/ProcessManager.py#L74-L75

So you just have to add ulimit -s unlimited; at the beginning of run_cmd:

"run_cmd": "ulimit -s unlimited; ./\"{file_name}\" {args} -debug"

i am getting this error in m1 mac. "/bin/sh: line 0: ulimit: stack size: cannot modify limit: Operation not permitted" when using "ulimit -s unlimited"

DeveloperKev avatar Sep 05 '23 10:09 DeveloperKev