6

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?

4

1 回答 1

12

This should work:

#define PRODUCTNAME     ((const unsigned char *)"SomeName")
于 2013-03-30T15:38:54.087 回答