Having a global DATE or DT variable causes the following error when the debugger compiles the C code:
Start build in /home/pi/Documents/minimal_case/build
Generating SoftPLC IEC-61131 ST/IL/SFC code...
Compiling IEC Program into C code...
Extracting Located Variables...
C code generated successfully.
PLC :
[CC] plc_main.c -> plc_main.o
[CC] plc_debugger.c -> plc_debugger.o
py_ext :
[CC] py_ext.c -> py_ext.o
PLC :
[CC] Config0.c -> Config0.o
[CC] Res0.c -> Res0.o
In file included from /home/pi/Documents/OpenPLC_Editor/matiec/lib/C/iec_std_FB.h:35,
from /home/pi/Documents/OpenPLC_Editor/matiec/lib/C/iec_std_lib.h:753,
from /home/pi/Documents/minimal_case/build/Res0.c:6:
/home/pi/Documents/minimal_case/build/Res0.c: In function ‘RES0_init__’:
/home/pi/Documents/minimal_case/build/Res0.c:27:48: error: initializer element is not constant
__INIT_GLOBAL(DATE,LOCALVAR0,__INITIAL_VALUE(__date_to_timespec(1, 1, 1970)),retain)
^~~~~~~~~~~~~~~~~~
/home/pi/Documents/OpenPLC_Editor/matiec/lib/C/accessor.h:60:31: note: in definition of macro ‘__INIT_GLOBAL’
static const type temp = initial;\
^~~~~~~
/home/pi/Documents/minimal_case/build/Res0.c:27:32: note: in expansion of macro ‘__INITIAL_VALUE’
__INIT_GLOBAL(DATE,LOCALVAR0,__INITIAL_VALUE(__date_to_timespec(1, 1, 1970)),retain)
^~~~~~~~~~~~~~~
"gcc" -c "/home/pi/Documents/minimal_case/build/Res0.c" -o "/home/pi/Documents/minimal_case/build/Res0.o" -O2 -fPIC "-I/home/pi/Documents/OpenPLC_Editor/matiec/lib/C" -Wno-unused-function
exited with status 1 (pid 14167)
C compilation of Res0.c failed.
C Build failed.
This doesn't happen for local variables or when the generated st file is uploaded to the runtime.
I put together a minimal test case to diagnose the issue:
minimal_case.tar.gz
Having a global DATE or DT variable causes the following error when the debugger compiles the C code:
This doesn't happen for local variables or when the generated st file is uploaded to the runtime.
I put together a minimal test case to diagnose the issue: minimal_case.tar.gz