Fix address offset bug after STRUCT variables #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Variables defined after STRUCT variables were assigned incorrect memory addresses, causing a systematic offset in the exported symbol addresses.
Root Cause
After parsing STRUCT variables, the parser did not align the bit address counter to the next 2-byte boundary before continuing with subsequent variables. This caused variables following STRUCTs to be placed at incorrect memory positions.
Example
ix_AutomaticStartgot addressDB320:0.3instead ofDB320:2.0DB320:2.0as expected in STEP 7Solution
Added 2-byte alignment (
_AlignUp(2 * 8)) at the end of_AddStructVariable()to ensure subsequent variables start at correct memory boundaries, maintaining STEP 7 memory layout compliance.Testing
Files Changed
src/EnlyzeS7PLib/src/CMc5codeParser.cpp: Added alignment after STRUCT processing