chprintf argument warning message

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

rew
Posts: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

chprintf argument warning message

Postby rew » Sun Mar 01, 2015 3:14 pm

I'm starting to use chprintf again. (stupid of me to try to prevent the code bloat because now I'm spending brain-cycles on stuff that is better done by a computer).

But I get this warning:

Code: Select all

In file included from main.c:20:0:
../ChibiOS_2.6.6/os/various/chprintf.h:69:20: note: expected 'struct BaseSequentialStream *' but argument is of type 'struct BaseSequentialStream *'
 static INLINE void chprintf(BaseSequentialStream *chp, const char *fmt, ...) {

The cast was initially put in my code as a copy-paste from the warning message as to what it wanted. But the warning doesn't go away and now it doesn't make sense...

What am I missing?

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: chprintf argument warning message

Postby Giovanni » Sun Mar 01, 2015 6:38 pm

I would verify the order of inclusions in your main.c,

Giovanni

rew
Posts: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: chprintf argument warning message

Postby rew » Tue Mar 03, 2015 6:26 pm

I verified it. But each time I look it stays in the same order. :-)

Code: Select all

#include "ch.h"
#include "hal.h"
#include "chprintf.h"

#include "string.h"
//#include <stdio.h>
#include "stdlib.h"
#include "stdarg.h"

#include "cmds.h"
#include "cmds_prototypes.h"
#include "cmds_table.h"

#include "bits.h"
#include "main.h"
#include "ow.h"

This order seems to be the same that demos use: first ch, then hal then chprintf. After the std... includes are my own.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: chprintf argument warning message

Postby Giovanni » Tue Mar 03, 2015 6:58 pm

Just a suggestion, put the standard headers first using the angular brackets < >.

Can you post your call to chprintf? I don't see that warning in my examples. Does this occur to you also on the provided demos?

Giovanni

colin
Posts: 149
Joined: Thu Dec 22, 2011 7:44 pm

Re: chprintf argument warning message

Postby colin » Fri Mar 06, 2015 1:27 am

Are there multiple BaseSequentialStream types in that version of ChibiOS? I think at some point there was one in the HAL and one in the RT kernel. Maybe gcc is confused.

Also is there more of the error message missing? It says "note:" which usually follows an actual warning or error message from gcc.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: chprintf argument warning message

Postby Giovanni » Fri Mar 06, 2015 10:04 am

The one in HAL is not used where the HAL is used with RT, that *should* not be the problem.

Giovanni

rew
Posts: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: chprintf argument warning message

Postby rew » Sun Mar 08, 2015 11:19 am

My "stdxxx.h" includes are now above the chibios includes. They now use angled brackets.

Code: Select all

In file included from main.c:31:0:
main.c: In function 'sd2puts':
main.h:118:26: warning: passing argument 1 of 'chprintf' from incompatible pointer type [enabled by default]
 #define ESP     ((struct BaseSequentialStream *)&SD2)
                          ^
main.c:460:13: note: in expansion of macro 'ESP'
   chprintf (ESP, "%s", p);
             ^
In file included from main.c:25:0:
../ChibiOS_2.6.6/os/various/chprintf.h:69:20: note: expected 'struct BaseSequentialStream *' but argument is of type 'struct BaseSequentialStream *'
 static INLINE void chprintf(BaseSequentialStream *chp, const char *fmt, ...) {
                    ^

The "sd2puts" used to call the write to sd2 directly, but while converting to use chprintf, I have this compatibility function that just prints the string using the "new" method...

Giovanni, the message should read something like: "expected 'float *' but argument is of type 'int *'", but apparently the types are different, but the textual representation for the warning message is the same.

So, your suggestion that it SHOULD not be the problem makes me suspicious that it actually IS the problem.

Well... My suspicions were wrong.... Searching for the definition(s) of BaseSequentialStream, I saw examples that used a cast to "(BaseSequentialStream *)&SDU1" instead of the "struct BaseSequentialStream *" that I was using.... I had copied the type from the warning message of gcc instead of from an example. Aaargh!

Correcting the casts and types resulted in many less warnings, leaving just a couple, where one was an actual bug that needed fixing....

Thanks for your help by the way!!


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 43 guests