cancel
Showing results for 
Search instead for 
Did you mean: 

New STM323 library incompatibility with C std type specifier

nikhilg171
Associate II
Posted on April 07, 2010 at 13:10

New STM323 library incompatibility with C std type specifier

7 REPLIES 7
Andrew Neil
Chief II
Posted on May 17, 2011 at 13:46

''I am getting a warning ''unsigned long *'' is in compatible with type ''uint32_t*'' . WHat should be done to remove this warning signal''

Obviously, use a type that is compatible with uint32_t !

Hint: check what size an ''unsigned long'' is with your particular compiler...

nikhilg171
Associate II
Posted on May 17, 2011 at 13:46

Hi,

  This is clear to me but still the problem is not clear to me. I am using new CMSIS compatible STM32 library.

Here in new lib u32 is defined as uint32_t which is also defined as __UINT32_T_TYPE__ in stdint.h. But I am not able to find the meaning of __UINT32_T_TYPE__  in any document.

Seeing the IAR compiler document, ''long'' is defined as 4 bytes only. So now I am not able to find correct way to remove this warning signal.

Do you have any idea?

Rgds,

Andrew Neil
Chief II
Posted on May 17, 2011 at 13:46

Are you using the IAR compiler?

Have you asked IAR about this?

Posted on May 17, 2011 at 13:46

Here in new lib u32 is defined as uint32_t which is also defined as __UINT32_T_TYPE__ in stdint.h. But I am not able to find the meaning of __UINT32_T_TYPE__  in any document.

 

I think you have this backward, because

typedef  __UINT32_T_TYPE__  uint32_t;

defines __UINT32_T_TYPE__ as uint32_t, not the other way around. Perhaps it's just your English.

As for uint32_t, it is probably defined as

typedef unsigned long int uint32_t;

Which given IAR's MISRA support probably isn't exactly the same as ''unsigned long''

Perhaps you should be using the (u32 *) or (uint32_t *) casts instead of using (unsigned long *). It's always good to use a uniform and consistent coding of types, rather than casting back and forth.

-Clive

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Chief II
Posted on May 17, 2011 at 13:46

''It's always good to use a uniform and consistent coding of types, rather than casting back and forth.''

Absolutely!

nikhilg171
Associate II
Posted on May 17, 2011 at 13:46

Hi Clive1,

  Thanks for the explanation. II agree that there should be a uniform way of using it but the problem is if you have some external library than what would you do.

Now coming to the problem. I know how to typecast but I want to understand the relation between __UINT32_T_TYPE__ and unsigned long. As I have some library in which only ''unsigned long'' is used while on the other hand in new STM32 lib u32 is defined as uint32_t which in turn is defined as uint32_t.

Hope the problem is clear now.

Rgds,

kevinow-wing9
Associate
Posted on May 17, 2011 at 13:46

It could be because uint32_t is really typedef'd as unsigned int...