Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I #define an unsigned char* string?

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?

like image 402
Dehalion Avatar asked Mar 30 '13 15:03

Dehalion


People also ask

How Do I Live Without You original artist?

1997 was an awkward year for LeAnn Rimes and Trisha Yearwood. If you don't recall, they were pitted against each other when songwriter Diane Warren commissioned both of them to sing the iconic track “How Do I Live” for the film Con Air.

How Do I Live Without You controversy?

It all began when Hollywood executives were putting the final touches on the 1997 Nicholas Cage film Con Air. "How Do I Live" written by Diane Warren was going to be included and they needed to find a singer. After some initial deliberation, they decided not to include the LeAnn Rimes version of the song in the film.


1 Answers

This should work:

#define PRODUCTNAME     ((const unsigned char *)"SomeName")
like image 142
thumbmunkeys Avatar answered Sep 18 '22 20:09

thumbmunkeys