user3000289
user3000289

Reputation:

What means multiple commas in a macro in c

What does this macro mean or what is the result?

#define MOD_TYPE_12 0x11, 0x20, 0x0C, 0x00, 0x02, 0x00, 0x07, 0x0F, 0x42, 0x40, 0x01, 0xC9, 0xC3, 0x80, 0x00, 0x02

Is this evaluated to an array?

I couldn't find anything... Maybe because I don`t know what I have to search for ^^

Upvotes: 1

Views: 72

Answers (2)

K.H.A.J.A.S
K.H.A.J.A.S

Reputation: 516

All the

MOD_TYPE_12

in your program will be replaced with

0x11, 0x20, 0x0C

There is no specialty with commas

Upvotes: 2

Kninnug
Kninnug

Reputation: 8053

The commas don't have any special meaning in a macro, they'll just be copied whereever the macro is used. For example:

int arr = {MOD_TYPE_12};

becomes

int arr = {0x11, 0x20, 0x0C, 0x00, 0x02, 0x00, 0x07, 0x0F, 0x42, 0x40, 0x01, 0xC9, 0xC3, 0x80, 0x00, 0x02};

Or:

someFunction(MOD_TYPE_12);

becomes

someFunction(0x11, 0x20, 0x0C, 0x00, 0x02, 0x00, 0x07, 0x0F, 0x42, 0x40, 0x01, 0xC9, 0xC3, 0x80, 0x00, 0x02);

Upvotes: 1

Related Questions