bugAVR C Runtime Library - Bugs: bug #41689, add static_assert to assert.h

 
 

bug #41689: add static_assert to assert.h

Submitted by:  azudem <azudem>
Submitted on:  Tue Feb 25 15:52:43 2014  
 
Category: Feature RequestSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: FixedPercent Complete: 0%
Assigned to: Pitchumani <pitchumani>Open/Closed: Closed
Release: AnyFixed Release: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

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

 

Wed Oct 19 10:38:18 2016, comment #3:

http://svn.savannah.nongnu.org/viewvc?view=rev&root=avr-libc&revision=2526

This patch has been applied and committed.

Thank you for the contribution.

Pitchumani <pitchumani>
Project MemberIn charge of this item.
Fri Oct 14 13:35:07 2016, comment #2:

I also recently discovered this problem (post on the mailing list). Please fix it as the solution is already provided in the comments. Thanks.

Nico <nicohood>
Wed Mar 11 16:22:58 2015, comment #1:

_Static_assert may be ugly, but it's what ISO C mandates:

http://en.cppreference.com/w/c/language/_Static_assert

static_assert is syntactic sugar imported by <assert.h>.

With gcc, here is a bit of confusion on which is defined when. gcc 4.6 supports _Static_assert, but assert.h has static_assert only when std==c11. In gcc 4.7, static_assert is defined by assert.h even if std!==c11 (apparently).

I use the following chunk of code to get as much as is available:

#if (_STDC_VERSION_ >= 201112L)
#include <assert.h>
#elif (_GNUC_ > 4 || (_GNUC_ == 4 && _GNUC_MINOR_ >= 6))
#define static_assert(condition, message) _Static_assert(condition, message)
#else
#define static_assert(condition, message)
#endif

Anonymous
Tue Feb 25 15:52:43 2014, original submission:

Add

#if defined __USE_ISOC11 && !defined __cplusplus
# undef static_assert
# define static_assert _Static_assert
#endif

to <assert.h>. Static assertions supported by GCC > 4.6 and very useful (especially for MCU coding). Default name '_Static_assert' is ugly.

azudem <azudem>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #33874:  0001-easy-C11-conformance.patch added by None (1kB - text/x-patch - Complete patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by pitchumani (Updated the item)
  • -unavailable- added by nicohood (Posted a comment)
  • -unavailable- added by azudem (Submitted the item)
  •  

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

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Oct 19 10:38:18 2016pitchumaniStatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Wed Oct 19 10:29:25 2016pitchumaniStatusNone=>Confirmed
      Assigned toNone=>pitchumani
      Summarystatic_assert=>add static_assert to assert.h
    Sat May 2 05:54:13 2015NoneAttached File-=>Added 0001-easy-C11-conformance.patch, #33874

    Back to the top


    Powered by Savane 3.1-cleanup