dhein
dhein

Reputation: 6555

How to make 64bit Preprocessor defined constant compile without warning?

Imagine this:

#define PUTVALUE 0x000000000000000F
#define SetStr(s) literate(s)
#define literate(s) #s

...

foo (PUTVALUE, SetStr(PUTVALUE));

How can I make work this, where foo wants as first parameter a 64 bit integer, and as second parameter a const string with a hexadecimal representation of that integer with leading 0x.

So I cant do:

#define PUTVALUE 0x000000000000000Full

as this would break the second parameter.

But not doing so is breaking the first.

Upvotes: 1

Views: 272

Answers (1)

dhein
dhein

Reputation: 6555

Oh I figgured just out an awesome way to do so:

foo (INT64_C(PUTVALUE), SetStr(PUTVALUE));

Is doing exactly that job.

Upvotes: 1

Related Questions