bugAVR C Runtime Library - Bugs: bug #36571, stdint.h: INTn_C not standard...

 
 

bug #36571: stdint.h: INTn_C not standard compliant

Submitted by:  Georg-Johann Lay <gjlayde>
Submitted on:  Thu 31 May 2012 08:02:57 PM UTC  
 
Category: HeaderSeverity: 3 - Normal
Priority: 9 - ImmediateItem Group: Header files
Status: NonePercent Complete: 0%
Assigned to: NoneOpen/Closed: Open
Release: 1.8.0Fixed Release: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 16 Nov 2012 11:00:00 PM UTC, comment #1:

Here is the output for -mint8:

$ echo | avr-gcc-4.7.2 -x c - -E -dM -mint8 | sort | grep 'INT.*_C'

#define __INT16_C(c) c ## L
#define __INT32_C(c) c ## LL
#define __INT8_C(c) c
#define __INTMAX_C(c) c ## LL
#define __UINT16_C(c) c ## UL
#define __UINT32_C(c) c ## ULL
#define __UINT8_C(c) c ## U
#define __UINTMAX_C(c) c ## ULL

Notice that simply adopting this does not work with macros. Just consider:

#define F_CPU 0x80000

long f (void)
{
return INT32_C (F_CPU);
}

which works with

#define INT32_C(c) __INT32_C(c)

but fails with

#define INT32_C(c) c ## L

Georg-Johann Lay <gjlayde>
Thu 31 May 2012 08:02:57 PM UTC, original submission:

C99: 7.18.4 Macros for integer constants

writes in clause #3 on the INTn_C function-like macros:

Each invocation of one of these macros shall expand
to an integer constant expression suitable for use
in #if preprocessing directives.

However, stdint.h defines respective macros like so

#define INT8_C(value) ((int8_t) value)

which cannot be used in #if preprocessing directives.

FYI, avr-gcc built-in defines similar macros like so, provided -mint8 is off:

$ echo | avr-gcc -x c - -E -dM | sort | grep 'INT.*_C'

#define __INT8_C(c) c
#define __INT16_C(c) c
#define __INT32_C(c) c ## L
#define __INT64_C(c) c ## LL
#define __INTMAX_C(c) c ## LL
#define __UINT8_C(c) c
#define __UINT16_C(c) c ## U
#define __UINT32_C(c) c ## UL
#define __UINT64_C(c) c ## ULL
#define __UINTMAX_C(c) c ## ULL

With -mint8 on, it should be something around (no appropriate compiler handy at the moment)

#define __INT8_C(c) c
#define __INT16_C(c) c ## L
#define __INT32_C(c) c ## LL
#define __INTMAX_C(c) c ## LL
#define __UINT8_C(c) c ## U
#define __UINT16_C(c) c ## UL
#define __UINT32_C(c) c ## ULL
#define __UINTMAX_C(c) c ## ULL

So avr-libc could adopt these or just

#define INT8_C(c) __INT8_C(c)

which works since gcc 4.5, maybe also 4.4.

Georg-Johann Lay <gjlayde>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by arcanum (Updated the item)
  • -unavailable- added by gjlayde (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 16 Nov 2012 06:17:47 PM UTCarcanumPriority5 - Normal=>9 - Immediate

    Back to the top


    Powered by Savane 3.1-cleanup