[cc65] ca65: Global scope specifier required in "constant expressions"??

From: Agent Friday <64subnet1gmail.com>
Date: 2011-07-05 03:45:54
I've been getting the "constant expression expected" error where I
don't think I should be.  I isolated the issue to the conditional
assembly directive being inside a .proc scope vs. being in global
scope.

To re-create:
==========================================
> cl65 --version
cl65 V2.13.2 - (C) Copyright 1998-2009 Ullrich von Bassewitz

> cl65 t.s
t.s(11): Error: Constant expression expected

> type t.s
USE_JOYPORT = 1
.CODE

.IF USE_JOYPORT
comm_port = $dc01
.ELSE
comm_port = $dd01
.ENDIF

.PROC test_irq
.IF USE_JOYPORT       ; <-- Line 11
  lda   #$F9
  sta   comm_port +2     ; ddr
.ENDIF
.ENDPROC

=========================================

I found that changing the second reference (the one inside the .PROC)
to ::USE_JOYPORT fixes the error, but it seems this should not be
necessary.

According to section 7.7 Scope Search Order, the search should
automatically look outward if a symbol is not found in the current
scope.  Is there some reason this isn't happening in this example?

Thanks,
// Agent Friday
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Jul 5 03:46:03 2011

This archive was generated by hypermail 2.1.8 : 2011-07-05 03:46:07 CEST