Closed yglukhov closed 2 years ago
I implemented a slightly different fix in https://github.com/PMunch/ratel/commit/7b0c0538c0221cebd7fd71d0a7a1ea115e6c052a. By making them globals it stopped Nim from creating the zeroing calls. I was also able to make it be defined by using let
which means that Nim shouldn't allow the user to try and modify it. That commit also improves upon the escaping procedures and now if you define the same literal string twice in your code it will only be saved to progmem once which is pretty neat. It also implements your trick to ensure that the header is imported wherever it is needed.
Hmm, I just tested this and it has a slight problem. By compiling the example from the website you get this C code (I've cut away anything not related to the PROGMEM stuff):
So it seems to work fine in the global scope, but then break inside the loop. This is the same behaviour as the old code. The trick to get it to import pgmspace.h is great though!