6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 10, 2024 2:17 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Sep 30, 2020 8:39 pm 
Offline

Joined: Wed Mar 20, 2019 7:14 pm
Posts: 28
Location: Rotterdam, The Netherlands
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


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 30, 2020 9:02 pm 
Offline

Joined: Fri Apr 15, 2016 1:03 am
Posts: 139
Does your macro definition occur before the .include ?


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 01, 2020 6:51 am 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1485
Location: Scotland
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:
        .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/


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 03, 2020 1:54 pm 
Offline

Joined: Wed Mar 20, 2019 7:14 pm
Posts: 28
Location: Rotterdam, The Netherlands
Thank you once again, people!
I got it to work.

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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: