Skip to main content
nikhilg171
Associate
Apr 7, 2010 11:10 AM UTC
Question

New STM323 library incompatibility with C std type specifier

Posted on April 07, 2010 at 13:10

New STM323 library incompatibility with C std type specifier

    This topic has been closed for replies.

    7 replies

    Andrew Neil
    Super User
    May 17, 2011 11:46 AM UTC
    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...

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    Andrew Neil
    Super User
    May 17, 2011 11:46 AM UTC
    Posted on May 17, 2011 at 13:46

    Are you using the IAR compiler?

    Have you asked IAR about this?

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    nikhilg171
    Associate
    May 17, 2011 11:46 AM UTC
    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,

    Tesla DeLorean
    Guru
    May 17, 2011 11:46 AM UTC
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    kevinow-wing9
    Visitor II
    May 17, 2011 11:46 AM UTC
    Posted on May 17, 2011 at 13:46

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

    nikhilg171
    Associate
    May 17, 2011 11:46 AM UTC
    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,

    Andrew Neil
    Super User
    May 17, 2011 11:46 AM UTC
    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!

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.