The linked code solves GC safety when compiled with threads. The problem is
that my procedure requires gcsafe even when not compiled with threads.
The code:
when compileOption("threads"):
var
SERVER_FIRST_MESSAGE_VAL: ptr Peg
SERVER_FINAL_MESSAGE_VAL: ptr Peg
template SERVER_FIRST_MESSAGE: Peg =
if SERVER_FIRST_MESSAGE_VAL.isNil:
SERVER_FIRST_MESSAGE_VAL = cast[ptr Peg](allocShared0(sizeof(Peg)))
SERVER_FIRST_MESSAGE_VAL[] = peg"'r='{[^,]*}',s='{[^,]*}',i='{\d+}$"
SERVER_FIRST_MESSAGE_VAL[]
template SERVER_FINAL_MESSAGE: Peg =
if SERVER_FINAL_MESSAGE_VAL.isNil:
SERVER_FINAL_MESSAGE_VAL = cast[ptr Peg](allocShared0(sizeof(Peg)))
SERVER_FINAL_MESSAGE_VAL[] = peg"'v='{[^,]*}$"
SERVER_FINAL_MESSAGE_VAL[]
else:
let
SERVER_FIRST_MESSAGE = peg"'r='{[^,]*}',s='{[^,]*}',i='{\d+}$"
SERVER_FINAL_MESSAGE = peg"'v='{[^,]*}$"
Run
The code is handling GC safety well by using a thread local variable when
compiled with threads. Why is gcsafe warning emitted when not compiled with
threads ?