This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: macro's and local variables


On 10/18/2012 10:30 AM, Jan Beulich wrote:
On 17.10.12 at 20:49, Mischa Baars <mjbaars1977@gmail.com> wrote:
Now try to uncomment the '.altmacro' directive if you like.
You _again_ did not read the documentation carefully enough:
Angle brackets (which is what C shift operators are made of)
can't be used verbatim in alternate macro mode.

Simply using

#define N (1 shl n)

instead makes the file assemble fine with .altmacro enabled.

Jan


Since I would like to interface with C, you would get as demonstrated in the attachments. I didn't know that 'shl' is accepted by the C compiler. Seems to work for now though.


Mischa.
#ifndef __COMMON_H__
#define __COMMON_H__

#define n 2
#define r 3

#define N (1 shl n)
#define R (1 shl r)

#endif

Attachment: function.S
Description: Text document

#include "common.h"

extern void function();

int main()
{
	function();
}

Attachment: makefile
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]