The term "precedence problem" has been borrowed from the official GNU C docs 1. The following sub-sections detail common pitfalls to macros that can be exploited in GML. Upon compilation, all occurrences of MESSAGE will be replaced with "hello world".
The symbol MESSAGE is the macro identifier and "hello world" is the piece of source code that the macro represents. Consider the following macro definition #macro MESSAGE "hello world" The most common application of macros in GML is to give synonyms to constants. Macros in GML use the #macro directive, and function similarly to C macros. As the name suggests, these constructs perform their tasks before or during compile-time, hence their disappearance once the build process of the program is complete. More specifically, macros are a form of compiler directive or preprocessor directive that enable developers to assign symbols to pieces of (commonly used) source code. Macros do not exist once the program is compiled, as they disappear once their job is done. This post assumes basic knowledge of what macros are, but for those that want a quick introduction: macros act as instructions to search for and replace some piece of code with another. Note: although macros are styled in SCREAMING_SNAKE_CASE by convention, all macro definitions in this post that resemble keywords will be in snake_case. Basic approaches to creating such syntax extensions are outlined throughout the post. Rather, this post is designed to make these ideas known to those who are interested. The aim of this post isn't to explore whether using macros as syntax extensions is practical, beneficial, or even a good idea. Using bad practices, careful design and creativity, macros can become a powerful feature for introducing new syntax into GameMaker Language (GML).