I want to set a FourCC value in C++, i.e. an unsigned 4 byte integer.
I suppose the obvious way is a #define, e.g.
#define FOURCC(a,b,c,d) ( (uint32) (((d)<<24) | ((c)<<16) | ((b)<<8) | (a)) )
and then:
uint32 id( FOURCC('b','l','a','h') );
What is the most elegant way you can think to do this?
I see nothing wrong with your algorithm. But for something like this I would just write a function instead of a macro. Macros have a lot of hidden features / problems that can bite you over time.