0

I am using c++ and GO from the first answer of this post

I know that In c++ there is a default maximum stack size of 1MB (on windows). To increase that limit with with gcc and g++ I read this forum post. This answer seemed correct

Well, I don't know if you can set it to unlimited, but (assuming Windows) you can try passing -Wl,--stack,<size> (where <size> is in bytes) to set the stack size.

(From doing some tests, it seems the default is 2 MB)

How can I pass the same thing through cgo?

Ank i zle
  • 2,089
  • 3
  • 14
  • 36
  • 1
    A maximum stack size, if there is one, for C and/or C++ is implementation-specific. Be sure your particular C++ implementation uses this `-Wl` option before you proceed with questions of how to get -Wl with cgo. Then see https://stackoverflow.com/q/28710276/1256452 (though there is no accepted answer there). – torek Mar 18 '20 at 05:17
  • @torek there's nothing to do with compiler flags, because C functions are being called on a thread created on Go side, it's 1gb on 64 bit system. All what he can do is unsafly linkname maxstacksize from the runtime and apply new for whole program – Laevus Dexter Mar 18 '20 at 09:57
  • @LaevusDexter Typically for C or C++ POSIX style threads there is a per-thread system stack. On Linux one manipulates this with `pthread_attr`. You'd launch into C or C++ code, use the pthread code to create a new thread whose size you'd pre-set, and then either wait for the pthread, or return to the Go runtime. I have no idea how this all works on Windows though. – torek Mar 18 '20 at 11:11

0 Answers0