cancel
Showing results for 
Search instead for 
Did you mean: 

How to use a macro in ASM file but it is defined in .h file?

ray
Associate II
Posted on June 28, 2014 at 10:46

I define a macrio in .h file using C language:#define VERSION 0x01.But I want to use it in an ASM file. How can I reference it? I try to #include ''*.h'', but it failed.

5 REPLIES 5
Dmitry Bravikov
Associate II
Posted on June 28, 2014 at 11:50

It is not possibly. Assembler doesn't know about C language.

stm322399
Senior
Posted on June 28, 2014 at 13:25

It's a feature that depends on your toolchain.

Example: using GNU toolchain, assembly file  (*.S) are first sent to the C preprocessor, where header files can be included, and macro expanded.

Which toolchain do you use ?

Andrew Neil
Evangelist III
Posted on June 28, 2014 at 20:46

''Assembler doesn't know about C language''

As already noted, it depends on the Assembler.

eg

http://www.keil.com/forum/8313/

RTFM for the particular assembler in question...
Andrew Neil
Evangelist III
Posted on June 28, 2014 at 20:51

As suggested in the

http://www.keil.com/forum/8313/

, even if the Assembler in question doesn't support 'C' headers, you could pass the source file through the

'C'

preprocessor - to deal with #include, #define, #if, etc -

before

giving it to the Assembler...
ray
Associate II
Posted on June 29, 2014 at 05:07

Thanks your reply. I use MDK-ARM in keil.