You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, sjasmplus does not seem to support commands for conditional compilation (e.g. IF/ENDIF) inside of STRUCT. However, I have seen on several occasions now that it would be a nice way to adapt data structures to changes in the setup due to user-specified configuration defined via a selection of definitions in the header. Because of this limitation I end up having to
IFDEF AddField3
STRUCT DATA
Field1 DB 0
Field2 DW 0
Field3 DB 0
ENDS
ELSE
STRUCT DATA
Field1 DB 0
Field2 DW 0
ENDS
ENDIF
instead of simply saying
STRUCT DATA
Field1 DB 0
Field2 DW 0
IFDEF AddField3
Field3 DB 0
ENDIF
ENDS
The issue is not even to do with the fact that we end up with more lines of code, but more to do with the fact that we have to copy and edit separately two identical copies of essentially the same code.
Describe the suggested solution:
It would be nice to be able to use IF/ELSE/ENDIF (as well as other conditional compilation commands) inside of STRUCT/ENDS.
The text was updated successfully, but these errors were encountered:
workaround-proposal: you can substitute whole line of the struct definition through DEFINE, ie.:
DEFINE OPT_FIELD3 Field3 DB 0
STRUCT DATA
Field1 DB 0
Field2 DW 0
OPT_FIELD3
Field4 DB 1
ENDS
ASSERT 5 == DATA ; DATA is 5 bytes in total
; redefine OPT_FIELD3 to empty define
DEFINE+ OPT_FIELD3
STRUCT DATA2
Field1 DB 2
Field2 DW 3
OPT_FIELD3
Field4 DB 4
ENDS
ASSERT 4 == DATA2 ; DATA2 is 4 bytes in total
DATA {0,1,2,3}
DATA2 {4,5,6}
I still like the idea of conditionals working inside struct def, but not going to try to bend current parser for it, the current architecture would either need quite some duplicity of code to parse it, or refactoring the architecture first to parse source a bit differently, so marking this as "v2.x" proposal.
Is your feature request related to a problem?
Currently, sjasmplus does not seem to support commands for conditional compilation (e.g. IF/ENDIF) inside of STRUCT. However, I have seen on several occasions now that it would be a nice way to adapt data structures to changes in the setup due to user-specified configuration defined via a selection of definitions in the header. Because of this limitation I end up having to
instead of simply saying
The issue is not even to do with the fact that we end up with more lines of code, but more to do with the fact that we have to copy and edit separately two identical copies of essentially the same code.
Describe the suggested solution:
It would be nice to be able to use IF/ELSE/ENDIF (as well as other conditional compilation commands) inside of STRUCT/ENDS.
The text was updated successfully, but these errors were encountered: