in many code i see that type of "something". anybody explain please.
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
8 | awoo | 154 |
10 | luogu_official | 151 |
in many code i see that type of "something". anybody explain please.
Name |
---|
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.