midul's blog

By midul16 months ago, In English,

in many code i see that type of "something". anybody explain please.

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

 
»
16 months ago, # |
  Vote: I like it +3 Vote: I do not like it

It sets stack size. If you don't write it, your solution may crash with stack overflow (in deep recursive functions, for example).

  •  
    »
    »
    16 months ago, # ^ |
      Vote: I like it +15 Vote: I do not like it

    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).

    •  
      »
      »
      »
      16 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      thats nice. by the by whats the default gcc stack size?

      •  
        »
        »
        »
        »
        16 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        2MB. You can see this in the headers of .exe produced by MinGW.

    •  
      »
      »
      »
      16 months ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it
      $ g++ -Wl,--stack=256000000 test.cpp
      /usr/bin/ld: unrecognized option '--stack=256000000'
      /usr/bin/ld: use the --help option for usage information
      

      Parameter --stack can be used only with MinGW. ;)

      •  
        »
        »
        »
        »
        16 months ago, # ^ |
          Vote: I like it -13 Vote: I do not like it

        so how increase stack in g++ under CNU/Linux?

        •  
          »
          »
          »
          »
          »
          16 months ago, # ^ |
            Vote: I like it +13 Vote: I do not like it

          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.

 
»
15 months ago, # |
  Vote: I like it +8 Vote: I do not like it

“#pragma comment(linker, ”/STACK:36777216“)” Is it usable only in the on-line judge or anywhere you want?

  •  
    »
    »
    15 months ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    It's usable anywhere with Microsoft Visual C++ — on your local machine and so on.