Menu

#3513 c macro expansion in asm comments

open
nobody
None
Preprocessor
5
2022-10-30
2022-10-29
Under4Mhz
No

C macros get expanded in asm comments:

// GPL 2.0 or later
#define wait \
    wait:    \
    dec a   \
    jp nz, wait

void vdu_sprite_init() {

    __asm

    ;; Copy dma wait routine to himem

    __endasm;
}
sdcc -mz80 -c ./macro_in_comment.c 
./macro_in_comment.c:7: warning 283: function declarator with no prototype
macro_in_comment.asm:51: Error: <q> missing or improper operators, terminators, or delimiters
removing macro_in_comment.rel
_vdu_sprite_init::
;./macro_in_comment.c:12: __endasm;
;;  Copy dma wait: 
    dec a 
    jp nz, wait routine to himem
;./macro_in_comment.c:13: }
    ret

That's what I get for giving my macros such a poorly conceived name.

Discussion

  • Benedikt Freisen

    • Category: other --> Preprocessor
     
  • Benedikt Freisen

    This is probably closely related to [bugs:#3512].
    AFAIK, the current preprocessor simply does not know what a comment in the target assembly language looks like and therefore treats it like any other piece of assembly code, i.e. code where macros are permitted.

     

    Related

    Bugs: #3512


Log in to post a comment.

Auth0 Logo