in many code i see that type of "something". anybody explain please.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
in many code i see that type of "something". anybody explain please.
Название |
---|
It sets stack size. If you don't write it, your solution may crash with stack overflow (in deep recursive functions, for example).
The only thing to add is that it's MS Visual C++-specific and won't work with GCC. In GCC you should specify
-Wl,--stack=256000000
command line option to set stack size (in bytes).thats nice. by the by whats the default gcc stack size?
2MB. You can see this in the headers of .exe produced by MinGW.
Parameter
--stack
can be used only with MinGW. ;)so how increase stack in g++ under CNU/Linux?
Nohow. Stack size is a user limit under GNU/Linux and doesn't depend on compiler. You can use
ulimit -s
to change/view it.can you tell me exactly what should I write in the code for GCC compiler to increase the stack size?
If inline assembler is allowed, you can allocate a block of memory using
malloc
and move the stack pointer to that newly allocated block. AFAIK, it's the only way of increasing the stack size from the code in GCC. Sorry, but I don't know AT&T syntax, which is used by GNU Assembler, so I can't write the code.But in MSVC (which uses Intel syntax) it'd look like this:
UPD. Fixed an error.
You are not able to modify stack size from source code using GCC, afaik (however, I've heard that there were some extensions in the latest versions of GCC, but I don't know exactly). The only way to do so was described above. For example, in Windows you can use the following command line:
g++ -o app.exe -Wl,--stack=256000000 -O2 source.cpp
Thanks both of you very much.
“#pragma comment(linker, ”/STACK:36777216“)” Is it usable only in the on-line judge or anywhere you want?
It's usable anywhere with Microsoft Visual C++ — on your local machine and so on.