• AVR Freaks

Hot!MICROCHIP_XC16 macro?

Author
RoboDLC
Super Member
  • Total Posts : 400
  • Reward points : 0
  • Joined: 2006/03/03 10:49:45
  • Location: Colorado
  • Status: offline
2020/02/24 14:37:39 (permalink)
0

MICROCHIP_XC16 macro?

My legacy project code was used in both MPLAB/C30 and IAR workbench compilers.  To make sure both IDE/compiler combinations worked properly with "packed" arrays in their respective sandboxes I used this check:
#ifdef MICROCHIP_C30
#define PACKED_C30    __attribute__((packed))
#else
#define PACKED_C30
#endif

// Do NOT use __packed in structs that have pointers for IAR compilers.
#ifdef    __ICCARM__
#define PACKED_EWARM    __packed
#else
#define PACKED_EWARM
#endif

Is there a similar macro defined in XC16?  My Google foo has not turned up such a thing.  I can obviously re-arrange my test to get similar results, but if such a thing exists - I am not even sure whether the IDE or the compiler defined that macro...
 
DLC
 

DLC
Robotics hobbyist, firmware engineer
dlc@frii.com
#1

4 Replies Related Threads

    ric
    Super Member
    • Total Posts : 26058
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: MICROCHIP_XC16 macro? 2020/02/24 14:46:14 (permalink)
    +1 (1)
    Wouldn't you look in the XC16 User Guide before resorting to Google?
    Particularly section "19.4 PREDEFINED MACRO NAMES"
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    steverap
    Super Member
    • Total Posts : 162
    • Reward points : 0
    • Joined: 2003/11/07 12:38:54
    • Location: San Jose, CA, USA
    • Status: offline
    Re: MICROCHIP_XC16 macro? 2020/02/24 14:47:39 (permalink)
    0
    Try:
     
    #ifdef __XC16__
    ...
    #endif
     
    Look at the compiler's user guide found in the doc directory of your compiler installation.
    #3
    du00000001
    Just Some Member
    • Total Posts : 3459
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: MICROCHIP_XC16 macro? 2020/02/24 14:59:09 (permalink)
    +2 (4)
    Why should one have a look into the docs when there is a "tool" like giggle ?  grin

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #4
    aschen0866
    Super Member
    • Total Posts : 4544
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re: MICROCHIP_XC16 macro? 2020/02/24 16:39:07 (permalink)
    +3 (3)
    dlc@frii.com
    #ifdef MICROCHIP_C30
    #define PACKED_C30    __attribute__((packed))
    #else
    #define PACKED_C30
    #endif

    // Do NOT use __packed in structs that have pointers for IAR compilers.
    #ifdef    __ICCARM__
    #define PACKED_EWARM    __packed
    #else
    #define PACKED_EWARM
    #endif



    Using different macro names for different compilers somewhat defeats the purpose. I would probably just call it PACKED_STRUCT, which becomes, for example,
    #define PACKED_STRUCT struct __attribute__((packed))
    or
    #define PACKED_STRUCT struct
    depending upon the platform.
    #5
    Jump to:
    © 2020 APG vNext Commercial Version 4.5