How do I #define an unsigned char* string?

Dehalion picture Dehalion · Mar 30, 2013 · Viewed 25.5k times · Source

I have following define in my code

#define PRODUCTNAME     "SomeName"

and I want to send it with a function com_reply(unsigned char* msg, uint16_t lenght).

Now I get a warning that my argument differs in signedness. I know what the problem is and also why com_reply uses unsigned char* instead of char*, I just want to know:

How can I define my string as an unsigned char* so I can use it throughout my program without getting warnings all over the place.

EDIT:

Strictly speaking I have more than one defines here and the main reason is that there is a BANNER define which consists of several other defines, like this:

#define PRODUCTNAME     "SomeName"
#define PRODUCTDATE     "2013-03-30"
#define BANNER          PRODUCTNAME " (" PRODUCTDATE ")"

Should I create const variables and concatenate them at program start instead of using defines here?

Answer

thumbmunkeys picture thumbmunkeys · Mar 30, 2013

This should work:

#define PRODUCTNAME     ((const unsigned char *)"SomeName")