|
Warning 167Next Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Sauli Porttila Posted 8-Apr-2006 06:10 Toolset ARM |  Warning 167 Sauli Porttila Howcome is it that the following code:
#include <string.h>
static unsigned char buf[ 20];
void func( void)
{
strcpy( buf, "huuhaa");
}
gives warning:
huuhaa.c(7): warning: #167-D: argument of type "unsigned char *" is incompatible with parameter of type "char *"
even though strcpy prototype in string.h is:
extern unsigned char *strcpy (unsigned char *s1, const unsigned char *s2);
?? | | Read-Only Author Reinhard Keil Posted 8-Apr-2006 06:40 Toolset ARM |  RE: Warning 167 Reinhard Keil The header file you are looking at is the CARM header file. But you are using the RealView Compiler which uses the header file in the folder ARM\RV30\INC\STRING.H. This header file defines the string functions with plain char datatypes and therefore a cast operation is required to avoid warnings.
void func( void) {
strcpy( (char *) buf, "huuhaa");
}
| | Read-Only Author Sauli Porttila Posted 9-Apr-2006 02:37 Toolset ARM |  RE: Warning 167 Sauli Porttila In that case uVision opens the wrong file when right clicking the included file name and selecting 'Open document'. | | Read-Only Author Sauli Porttila Posted 9-Apr-2006 04:34 Toolset ARM |  RE: Warning 167 Sauli Porttila Further..
The compiler documentation says that the basic type char defaults to unsigned char (compiler option --unsigned_chars). Why the warning?
One of the MISRA rules states that the char type must always be declared signed or unsigned. There must be a good reason for this rule.
I know I can suppress the warning with --diag_suppress, but I don't think it is a good idea either. | |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|