CC/CA65 - Use macro's in included files

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
jaccodewijs
Posts: 29
Joined: 20 Mar 2019
Location: Rotterdam, The Netherlands

CC/CA65 - Use macro's in included files

Post by jaccodewijs »

Hello fellow-coders!

I am using CC65/CA65 to code for my 65C02 machine.
Does anyone of you know if and how i could use Macro's in included files?

Example:
i have a main file that includes another file using:

.include "extrafile.s"

That extrafile.s file uses macro's:

.macro somefunction
bla
bla
bla
etc.
.endmacro



This is where the compiler throws an error, because it doesn't recognize the macro's when included in the main file.

Is this at all possible? Or should i give up trying to use macro's in this way?
Thanks for the help, people!

Greetings,
Jacco
leepivonka
Posts: 167
Joined: 15 Apr 2016

Re: CC/CA65 - Use macro's in included files

Post by leepivonka »

Does your macro definition occur before the .include ?
User avatar
drogon
Posts: 1671
Joined: 14 Feb 2018
Location: Scotland
Contact:

Re: CC/CA65 - Use macro's in included files

Post by drogon »

I have a large amount of code that works like that - ie. an included file defines the macro which is then expanded in files that include that header file.

(It probably makes no difference, but I use the .h suffix for included 'header' files to make it more obvious)

Also, if you think about it, (and if you use it), doing something like:

Code: Select all

        .macpack        generic
pulls in macros from the standard cc65 library for you.

But (as above), make sure you have the .include line before you use the included macro your main file.

So double check the order they're included and declared it, but it all should work just fine.

-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
jaccodewijs
Posts: 29
Joined: 20 Mar 2019
Location: Rotterdam, The Netherlands

Re: CC/CA65 - Use macro's in included files

Post by jaccodewijs »

Thank you once again, people!
I got it to work.

Was indeed the order in which includes should be.
Thanks.
Post Reply