[bug #27201] _WORDREGISTER in xmega headers does not work in C99 mode

View: New views
6 Messages — Rating Filter:   Alert me  

[bug #27201] _WORDREGISTER in xmega headers does not work in C99 mode

by Laurent Destailleur-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


URL:
  <http://savannah.nongnu.org/bugs/?27201>

                 Summary: _WORDREGISTER in xmega headers does not work in C99
mode
                 Project: AVR C Runtime Library
            Submitted by: schneiso
            Submitted on: Fr 07 Aug 2009 10:41:28 GMT
                Category: Header
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Header files
                  Status: None
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 1.6.5
           Fixed Release: None

    _______________________________________________________

Details:

When using -std=c99 in conjunction with ATxmega128A1 the following example
code from the website for Xmega (Application node AVR1300: Using the XMEGA
ADC) does not compile for avr-gcc (Win-AVR20090313).

ADC_CH_t *acd_ch;
int16_t answer;
answer = adc_ch->RES;


This creates the following error message:
"error: 'ADC_CH_t' has no member named 'RES'

When looking at the corresponding header file iox128a1.h the type ADC_CH_t is
defined as such:

typedef struct ADC_CH_struct
{
    register8_t CTRL;  /* Control Register */
    register8_t MUXCTRL;  /* MUX Control */
    register8_t INTCTRL;  /* Channel Interrupt Control */
    register8_t INTFLAGS;  /* Interrupt Flags */
    _WORDREGISTER(RES);  /* Channel Result */
    register8_t reserved_0x6;
    register8_t reserved_0x7;
} ADC_CH_t;

The issue is caused be the definition of "_WORDREGISTER" in line 94:

#define _WORDREGISTER(regname)   \
    union \
    { \
        register16_t regname; \
        struct \
        { \
            register8_t regname ## L; \
            register8_t regname ## H; \
        }; \
    }


This does not work for C99, which (unfortunately) I need for my project.

The code works with IAR Workbench 5.30.02.




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27201>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #27201] _WORDREGISTER in xmega headers does not work in C99 mode

by Laurent Destailleur-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #1, bug #27201 (project avr-libc):

The problem is that accessing the union (and also struct,
for byte-wide access) elements without naming the union
itself is a GCC extension, so it is turned off when compiling
with -std=c99.

It appears to me that prepending the entire union declaration
with __extension__ does fix it by telling GCC "It's OK to use
the following GCC extension here, regardless of the --std
option in effect".

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27201>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #27201] _WORDREGISTER in xmega headers does not work in C99 mode

by Laurent Destailleur-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Additional Item Attachment, bug #27201 (project avr-libc):

File name: bug27201.patch                 Size:12 KB
File name: NEWS                           Size:37 KB
File name: ChangeLog                      Size:37 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27201>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #27201] _WORDREGISTER in xmega headers does not work in C99 mode

by Laurent Destailleur-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of bug #27201 (project avr-libc):

                  Status:                    None => Fixed                  
        Percent Complete:                      0% => 100%                  
             Assigned to:                    None => arcanum                
             Open/Closed:                    Open => Closed                
           Fixed Release:                    None => 1.6.8                  


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27201>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #27201] _WORDREGISTER in xmega headers does not work in C99 mode

by Laurent Destailleur-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of bug #27201 (project avr-libc):

                  Status:                   Fixed => None                  
        Percent Complete:                    100% => 90%                    
             Open/Closed:                  Closed => Open                  


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27201>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #27201] _WORDREGISTER in xmega headers does not work in C99 mode

by Laurent Destailleur-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of bug #27201 (project avr-libc):

                  Status:                    None => Fixed                  
        Percent Complete:                     90% => 100%                  
             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up Comment #2:

Ok, finally committed.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27201>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev