Discussion Forum

How do I code a command decoder without warnings?

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Detlef Keiler
Posted
7-Dec-2009 08:30 GMT
Toolset
ARM
New! How do I code a command decoder without warnings?

Hi,

this is a part of my command decoder:

const char Command_D[] = {"D"}; //Command in Memory
u8 In_Command[17]; //Command from USART

if (strcmp(Command_D, In_Command) == 0) { Run_Dump(); }

The code is compiled correctly and even works correctly, but the compiler says:

warning: #167-D: argument of type "unsigned char *" is incompatible with parameter of type "const char *"

I don't want to see a warning for each command to be
decoded. So how can I work around this issue?

Read-Only
Author
tamir michael
Posted
7-Dec-2009 08:42 GMT
Toolset
ARM
New! RE: How do I code a command decoder without warnings?

the compiler warning is quite clear: what does U8 stand for?

I don't want to see a warning for each command to be
decoded

No. this if a compilation time warning, not a runtime warning!

Read-Only
Author
Stefan Hartwig
Posted
7-Dec-2009 08:42 GMT
Toolset
ARM
New! RE: How do I code a command decoder without warnings?

Hi,
you may disable the warning in the compiler settings http://www.keil.com/support/man/docs/armccref/armccref_chdebied.htm
Or you may just cast the parameters to the right type

//int strcmp ( const char * str1, const char * str2 );
if (strcmp((const char*)Command_D, (const char*)In_Command) == 0)
{
    Run_Dump();
}

And make sure, that you understand, what you are doing...

Read-Only
Author
Detlef Keiler
Posted
7-Dec-2009 09:12 GMT
Toolset
ARM
New! RE: How do I code a command decoder without warnings?

Hi,

as I don't want to switch off the warnings I checked
the cast and it worked out fine.

Thanks!

Read-Only
Author
Andy Neil
Posted
7-Dec-2009 09:45 GMT
Toolset
None
New! RE: I checked the cast and it worked out fine

Rather than casting, why not just define things to the appropriate type in the first place?!

See my posts of 5-May-2009 08:58 GMT and 6-May-2009 00:24 GMT in this thread: http://www.keil.com/forum/docs/thread14769.asp

Next Thread | Thread List | Previous Thread Start a Thread | Settings