Problem
Environment
STruC++ version: 0.6.2
Platform: Windows 11 x64 (strucpp-win32-x64)
C++ compiler: g++ (MSYS2 UCRT64) 15.1.0, -std=c++17
Summary
strucpp parses and generates code fine, but the emitted C++ does not compile whenever a CASE statement switches on a value and uses VAR_GLOBAL CONSTANTs as the case labels. This is the exact idiom Simulink PLC Coder emits for every exported subsystem (CASE ssMethodType OF SS_INITIALIZE: ... SS_STEP: ...), so essentially no Simulink-generated .exp/.st file can be built with --build.
Impact
strucpp parses and generates code fine, but the emitted C++ does not compile whenever a CASE statement switches on a value and uses VAR_GLOBAL CONSTANTs as the case labels.
Reproduction
repro_case.st:
FUNCTION_BLOCK Stepper
VAR_INPUT
ssMethodType : SINT;
END_VAR
VAR_OUTPUT
y : INT;
END_VAR
CASE ssMethodType OF
MODE_INIT:
y := 0;
MODE_STEP:
y := y + 1;
END_CASE;
END_FUNCTION_BLOCK
PROGRAM Main
VAR
s : Stepper;
END_VAR
s(ssMethodType := MODE_STEP);
END_PROGRAM
VAR_GLOBAL CONSTANT
MODE_INIT : SINT := 0;
MODE_STEP : SINT := 1;
END_VAR
Build:
strucpp repro_case.st -o repro_case.cpp --no-default-libs --build
Code Locations
No response
Fix
No response
Acceptance
The example code can be compiled and run.
Problem
Environment
STruC++ version: 0.6.2
Platform: Windows 11 x64 (strucpp-win32-x64)
C++ compiler: g++ (MSYS2 UCRT64) 15.1.0, -std=c++17
Summary
strucpp parses and generates code fine, but the emitted C++ does not compile whenever a CASE statement switches on a value and uses VAR_GLOBAL CONSTANTs as the case labels. This is the exact idiom Simulink PLC Coder emits for every exported subsystem (CASE ssMethodType OF SS_INITIALIZE: ... SS_STEP: ...), so essentially no Simulink-generated .exp/.st file can be built with --build.
Impact
strucpp parses and generates code fine, but the emitted C++ does not compile whenever a CASE statement switches on a value and uses VAR_GLOBAL CONSTANTs as the case labels.
Reproduction
repro_case.st:
FUNCTION_BLOCK Stepper
VAR_INPUT
ssMethodType : SINT;
END_VAR
VAR_OUTPUT
y : INT;
END_VAR
CASE ssMethodType OF
MODE_INIT:
y := 0;
MODE_STEP:
y := y + 1;
END_CASE;
END_FUNCTION_BLOCK
PROGRAM Main
VAR
s : Stepper;
END_VAR
s(ssMethodType := MODE_STEP);
END_PROGRAM
VAR_GLOBAL CONSTANT
MODE_INIT : SINT := 0;
MODE_STEP : SINT := 1;
END_VAR
Build:
strucpp repro_case.st -o repro_case.cpp --no-default-libs --build
Code Locations
No response
Fix
No response
Acceptance
The example code can be compiled and run.