Help with macro

L

Lox

Hello

I would like to make a macro that does the following:

If i write:

BACKUP(X);

it should expand to:

copy((u8_t *)&place.X_work, (u8_t *)&place.X_backup,
sizeof(X_work_t));


How do i make the macro

This does not work:

#define BACKUP(x) nv_copy((u8_t *)&place.##block##_work, (u8_t
*)&place.##block##_backup, sizeof( ##block##_t))

Thank you.
 
J

Jive74

Il 24/10/2010 14.59, Lox ha scritto:
Hello

I would like to make a macro that does the following:

If i write:

BACKUP(X);

it should expand to:

copy((u8_t *)&place.X_work, (u8_t *)&place.X_backup,
sizeof(X_work_t));


How do i make the macro

This does not work:

#define BACKUP(x) nv_copy((u8_t *)&place.##block##_work, (u8_t
*)&place.##block##_backup, sizeof( ##block##_t))

Thank you.
This should work (don't know why you wrote block instead of x):

#define BACKUP(x) nv_copy((u8_t *)&place. x##_work, (u8_t *)&place.
x##_backup, sizeof( x##_t))

Giovanni
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Macro 3
Defining Macro in C 0
C macro 3
MACRO help 23
macro 41
Help with Loop 0
Macro Mystery ... help? 4
Hello and Help please :-) 1

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,216
Latest member
topweb3twitterchannels

Latest Threads

Top