flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > [fasmg] Protection against duplicated includes |
| Author |
|
|
bitRAKE 04 Jan 2026, 07:21
This might work for your use-case:
Code: ; We can make a global "#pragma once" mechanism if we assume all files have ; a unique path. Non-cannonical paths are fine as long as it's always the same ; form. Be mindful of file organization if you're going to use this. ; Primary benefits: ; + files are not loaded multiple times ; + no change to file needed (i.e. if/endif wrapper) calminstruction onetime?: line*& match name any?,line jyes go err 'filename expected' done: exit local val,var go: compute val,+name ; convert string to number arrange var,=ONETIME.val ; unique variable check definite var jyes done compute val,0 publish var:,val ; constant arrange line,=include line assemble line end calminstruction _________________ ¯\(°_o)/¯ AI may [not] have aided with the above reply. |
|||
|
|
bitRAKE 04 Jan 2026, 08:42
Jessé wrote: But I can't understand why the second one works. _________________ ¯\(°_o)/¯ AI may [not] have aided with the above reply. |
|||
|
|
Jessé 04 Jan 2026, 12:37
Nice, I did other tests and now it become clear.
Simply doubling the define statement inside if block also work (because it "pushes" another definition to the symbol, making it a variable definition, I guess). Which means my idea was not wrong, it just missing understanding how it works. The calminstruction example looks very interesting. I'll save it to test it further. |
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.