D-Programming-Language/dmd — pull request #1653 by andralex (2013-02-10 19:24:27+00:00)
Title: Allow support for undefined macros

Currently an undefined macro expands to the null string. With this pull request, if macro XYZ is used as e.g. $(XYZ arg1,arg2) without being defined, it is replaced with $(DDOC_UNEXPANDED_MACRO XYZ,arg1,arg2). If in turn DDOC_UNEXPANDED_MACRO is undefined, the expansion is the empty string (thus ensuring backward compatibility).

This allows users to define useful behaviors, such as:

a) replace with a comment:

DDOC_UNEXPANDED_MACRO=$(DDOC_COMMENT $(DOLLAR)($1 $+))

b) keep verbatim

DDOC_UNEXPANDED_MACRO=$(DOLLAR)($1 $+)

c) keep only the argument text

DDOC_UNEXPANDED_MACRO=$+

d) replace with a greppable text such that subsequent tools can find all occurrences:

DDOC_UNEXPANDED_MACRO=ERROR_UNDEFINED_MACRO: "$1"