This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Warning : #167-D - for function sprintf

Hello, colleagues!

My question is about work with function sprintf in Keil C for ARM.

I have a structure for RTC, that looking as:

struct {
	unsigned char		SEC;
	unsigned char		MIN;
	unsigned char		HOUR;
	unsigned char		DWEEK;
	unsigned char		DAY;
	unsigned char		MONTH;
	int		  	YEAR;
 } RTC8583;

I try to write function that showing time:

sprintf (BUFF,"%02d:%02d:%02d", 	
(unsigned)RTC8583.HOUR,(unsigned)RTC8583.MIN,(unsigned)RTC8583.SEC);

And after compilation, a message is displayed all the time:

...

compiling M1132_MAIN.c...

MAIN\M1132_MAIN.c(284): warning:  #167-D: argument of type "BYTE *" is incompatible with parameter of type "char *restrict"

                             sprintf (BUFF,"%02d:%02d:%02d", (unsigned)RTC8583.HOUR,(unsigned)RTC8583.MIN,(unsigned)RTC8583.SEC);

MAIN\M1132_MAIN.c: 1 warning, 0 errors

...  

 

I can’t understand how to do it right so that there is no warning!

It is still strange that neither in Borland C++, nor in Keil C for C51 such a   is observed!

Help me please!

 

Parents
  • Hi Oleg,

    I can't replicate this with trivial examples, how is BUFF defined? Signed or unsigned char* ? I get different errors (rather than warnings) if I use unsigned chars, but the below builds fine for me with both armcc and armclang.

    #include <stdio.h>
    
    extern char BUFF1[10];
    extern char BUFF2[];
    extern char* BUFF3;
    
    struct {
    	unsigned char		SEC;
    	unsigned char		MIN;
    	unsigned char		HOUR;
    	unsigned char		DWEEK;
    	unsigned char		DAY;
    	unsigned char		MONTH;
    	int		  	YEAR;
     } RTC8583;
    
    
     void foo(){
       sprintf (BUFF1,"%02d:%02d:%02d",(unsigned)RTC8583.HOUR,(unsigned)RTC8583.MIN,(unsigned)RTC8583.SEC);
       sprintf (BUFF2,"%02d:%02d:%02d",(unsigned)RTC8583.HOUR,(unsigned)RTC8583.MIN,(unsigned)RTC8583.SEC);
       sprintf (BUFF3,"%02d:%02d:%02d",(unsigned)RTC8583.HOUR,(unsigned)RTC8583.MIN,(unsigned)RTC8583.SEC);
    
       return;
    }
    


    Regards

    Ronan

Reply
  • Hi Oleg,

    I can't replicate this with trivial examples, how is BUFF defined? Signed or unsigned char* ? I get different errors (rather than warnings) if I use unsigned chars, but the below builds fine for me with both armcc and armclang.

    #include <stdio.h>
    
    extern char BUFF1[10];
    extern char BUFF2[];
    extern char* BUFF3;
    
    struct {
    	unsigned char		SEC;
    	unsigned char		MIN;
    	unsigned char		HOUR;
    	unsigned char		DWEEK;
    	unsigned char		DAY;
    	unsigned char		MONTH;
    	int		  	YEAR;
     } RTC8583;
    
    
     void foo(){
       sprintf (BUFF1,"%02d:%02d:%02d",(unsigned)RTC8583.HOUR,(unsigned)RTC8583.MIN,(unsigned)RTC8583.SEC);
       sprintf (BUFF2,"%02d:%02d:%02d",(unsigned)RTC8583.HOUR,(unsigned)RTC8583.MIN,(unsigned)RTC8583.SEC);
       sprintf (BUFF3,"%02d:%02d:%02d",(unsigned)RTC8583.HOUR,(unsigned)RTC8583.MIN,(unsigned)RTC8583.SEC);
    
       return;
    }
    


    Regards

    Ronan

Children