A bit of background:
The macro expansion library is completely generic, i.e. it does string replacement, that's it. It is independent from any lexer or parser and unaware of the context it is being used in.
The database file parser calls the macro expansion at the beginning of the chain, before doing the parsing.
Calling the macro expansion from inside of the parser, after determining the context (because e.g. a hash mark inside a string value does not start a comment), would require major changes, which IMHO bears too much risk compared to the minor gain of suppressing an unwanted warning. A warning that is technically correct, as you do have an undefined macro at this point.
To not lose the information in the commented line, I would suggest quoting the dollar sign (\$) which will remove its special meaning and silence the macro expansion engine.
Cheers,
~Ralph