I was able to fix it in my case by converting the following variables to the "Construct On First Use Idiom" (described just below the above link, on the same page): PIN_INDEX, BSPM_TEMPLATE and BSPWM_TEMPLATE.
The fix (which worked for me) is below, and won't affect the function of the library, just make it more portable/predictable across different compilers. Essentially it just enforces a functional initialization order.
In the memGPIO.cpp:
add the following instead of the current static initialization of the above variables:
Hi there,
I am running into static initialization order issues with this library in its current form (aka the "Static initialization order fiasco" see: https://isocpp.org/wiki/faq/ctors#static-init-order ).
I was able to fix it in my case by converting the following variables to the "Construct On First Use Idiom" (described just below the above link, on the same page): PIN_INDEX, BSPM_TEMPLATE and BSPWM_TEMPLATE.
The fix (which worked for me) is below, and won't affect the function of the library, just make it more portable/predictable across different compilers. Essentially it just enforces a functional initialization order.
In the memGPIO.cpp:
add the following instead of the current static initialization of the above variables:
In memGPIO.hpp, replace the variable declarations with the following function declarations:
Finally, in memGPIO.cpp, replace all uses of PIN_INDEX with PIN_INDEX(), BSPM_TEMPLATE with BSPM_TEMPLATE(), and PSPWM_TEMPLATE with PSPWM_TEMPLATE().