gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > GNU CPP and assembly question

#5211 - SmileyDude - Wed Apr 23, 2003 8:00 am

Hey everyone -- hopefully, this is an easy question :)

I'm using the GNU CPP with my assembly files, so I can get things like #define, #ifdef, etc, etc from my .S files. I'm trying to put together a common gba.h file that I can use for both assembly and C/C++ code, but I need to be able to tell if I am #included from a .S or a .c file -- is there anything I can #ifdef for that would tell me that I'm being included from a .S file?

As a workaround, I can just do the kludge of #define __ASSEMBLY__ before including my header file, but I would prefer to have this automated if possible...
_________________
dennis

#5291 - Touchstone - Thu Apr 24, 2003 5:44 pm

You can add a preprocessor directive from the command-line. At least for the C compiler. I'm pretty sure it's the -D option. Maybe that works for 'as' aswell. Just add it to your makefile or whatever.

I'm talking about GCC here, just to clarify. :)
_________________
You can't beat our meat

#5691 - SmileyDude - Tue May 06, 2003 6:14 am

Touchstone wrote:
You can add a preprocessor directive from the command-line. At least for the C compiler.


Now that's an interesting method -- one that I was aware of, but just completely forgot about for this problem. Since I'm using gcc for the asm files, I can easily put in a -D option. Small makefile change that's guarenteed to work as opposed to trying to find an existing #define... looks like I have a solution :)

thanks!
_________________
dennis