1
0
mirror of https://github.com/cc65/cc65.git synced 2025-04-09 10:39:40 +00:00

Add some warnings about using .DEFINE.

git-svn-id: svn://svn.cc65.org/cc65/trunk@5397 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2012-01-13 15:58:17 +00:00
parent 8ddcbc5f01
commit 6c490ba16c

View File

@ -823,13 +823,19 @@ convenient in some situations, so it's your decision.
<sect1>Using macros to define labels and constants<p>
While there are drawbacks with this approach, it may be handy in some
situations. Using <tt><ref id=".DEFINE" name=".DEFINE"></tt>, it is
possible to define symbols or constants that may be used elsewhere. Since
the macro facility works on a very low level, there is no scoping. On the
other side, you may also define string constants this way (this is not
While there are drawbacks with this approach, it may be handy in a few rare
situations. Using <tt><ref id=".DEFINE" name=".DEFINE"></tt>, it is possible
to define symbols or constants that may be used elsewhere. One of the
advantages is that you can use it to define string constants (this is not
possible with the other symbol types).
Please note: <tt/.DEFINE/ style macros do token replacements on a low level,
so the names do not adhere to scoping, diagnostics may be misleading, there
are no symbols to look up in the map file, and there is no debug info.
Especially the first problem in the list can lead to very nasty programming
errors. Because of these problems, the general advice is, <bf/NOT/ do use
<tt/.DEFINE/ if you don't have to.
Example:
<tscreen><verb>
@ -2247,6 +2253,11 @@ Here's a list of all control commands and a description, what they do:
Start a define style macro definition. The command is followed by an
identifier (the macro name) and optionally by a list of formal arguments
in braces.
Please note that <tt/.DEFINE/ shares most disadvantages with its C
counterpart, so the general advice is, <bf/NOT/ do use <tt/.DEFINE/ if you
don't have to.
See also the <tt><ref id=".UNDEFINE" name=".UNDEFINE"></tt> command and
section <ref id="macros" name="Macros">.