Re: [cc65] Another bug, with preprocessor macros

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-07-13 12:56:57


On Sat, Jul 12, 2003 at 11:26:24PM -0700, David Holz wrote:
> .ifdef, .ifndef, .def, and .defined all seem to throw a "Error #24:
> Identifier expected" when the macro is already defined, ie:
>
> .define BLAH
> .ifndef BLAH  ; <- error gets tossed here
> .define BLAH
> .endif
>
> The same error gets thrown when you try to redefine a macro, instead of a
> "Identifier already in use" type of message.

This is a misunderstanding. .ifdef/.ifndef do not work with macros, they work
with symbols:

        HAVE_REU        = 1
        ...
        .ifdef HAVE_REU
        ...
        .endif

.define creates low level macros, you should avoid it if you can. It was added
to allow emulation of features some other assembler had. Macros created with
.define do not obey scoping, and they are handled in a very early translation
phase, which means that you can do some really nasty things with them. The code

        .define BLAH

defines BLAH to be replaced by nothing whenever the token is found in the
input stream. This is the reason why

        .ifdef BLAH

causes an "Identifier expected" error. Since BLAH is removed, there is no
argument for .ifdef.

As said above, I would suggest to avoid the low level macros and use the high
level ones instead. They are much more predictable.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-07-13 12:57:05 CEST