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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #41689: add static_assert to assert.h

Submitter:  azudem <azudem>
Submitted:  Tue 25 Feb 2014 03:52:43 PM UTC
   
 
Category:  Feature Request Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Fixed Assigned to:  pitchumani
Percent Complete:  0% Open/Closed:  Closed
Release:  Any Fixed Release:  None

Sat 01 Sep 2018 01:54:26 PM UTC, comment #4: 

Are there any plan for a new avr-libc version? I am still waiting for this fix to get applied, maybe it would sense to release a new one to include this and other fixes?

Nico <nicohood>
Wed 19 Oct 2016 10:38:18 AM UTC, 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>
Group Member
Fri 14 Oct 2016 01:35:07 PM UTC, 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 11 Mar 2015 04:22:58 PM UTC, 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 25 Feb 2014 03:52:43 PM UTC, 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.)

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

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-10-19 pitchumani StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-10-19 pitchumani StatusNone Confirmed
        Assigned toNone pitchumani
        Summarystatic_assert add static_assert to assert.h
    2015-05-02 None Attached File- Added 0001-easy-C11-conformance.patch, #33874

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code