-
-
Notifications
You must be signed in to change notification settings - Fork 179
Description
The advantage of these constants in C is that they're not affected by macros, so you can have a "utilities.h":
#define crash(msg) exit((fprintf(stderr, "%s(%d): %s", __FILE__, __LINE__, msg), 1))And then crash("oops"); on line 42 of main.c will print "main.c(42): oops", not "utilities.h(6): oops".
On the other hand, rgbasm does not work like that. __FILE__ and __LINE__ use their deepest context in the fstack of include, rept, and macro nodes. So they're only useful for local reporting, but then, you already know what line you're on when you write them.
If anything, it would be more useful to expose other dynamic information. Such as the current section name, which #1066 would allow with SECTION(@). Or the current "label scope", a concept which is mentioned in rgbasm(5) but not currently accessible. (Similar to __func__ in C99, or __FUNCTION__ in gcc prior to that.) That would let you do this in utilities.inc:
MACRO error
FAIL STRFMT("In section \"%s\", label %s: %s", SECTION(@), __LABELSCOPE__, \1)
ENDM