[bug #41689] static_assert

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #41689] static_assert

Matthijs Kooijman-2
URL:
  <http://savannah.nongnu.org/bugs/?41689>

                 Summary: static_assert
                 Project: AVR C Runtime Library
            Submitted by: azudem
            Submitted on: Tue 25 Feb 2014 15:52:43 GMT
                Category: Feature Request
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
        Percent Complete: 0%
             Assigned to: None
        Originator Email:
             Open/Closed: Open
         Discussion Lock: Any
                 Release: Any
           Fixed Release: None

    _______________________________________________________

Details:

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.




    _______________________________________________________

Reply to this item at:

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

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


_______________________________________________
AVR-libc-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev
Reply | Threaded
Open this post in threaded view
|

[bug #41689] static_assert

Matthijs Kooijman-2
Follow-up Comment #1, bug #41689 (project avr-libc):

_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

    _______________________________________________________

Reply to this item at:

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

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


_______________________________________________
AVR-libc-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev
Reply | Threaded
Open this post in threaded view
|

[bug #41689] static_assert

Matthijs Kooijman-2
Additional Item Attachment, bug #41689 (project avr-libc):

File name: 0001-easy-C11-conformance.patch Size:1 KB


    _______________________________________________________

Reply to this item at:

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

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


_______________________________________________
AVR-libc-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev
Reply | Threaded
Open this post in threaded view
|

[bug #41689] static_assert

Matthijs Kooijman-2
Follow-up Comment #2, bug #41689 (project avr-libc):

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

    _______________________________________________________

Reply to this item at:

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

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


_______________________________________________
AVR-libc-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev
Reply | Threaded
Open this post in threaded view
|

[bug #41689] add static_assert to assert.h

Matthijs Kooijman-2
Update of bug #41689 (project avr-libc):

                  Status:                    None => Confirmed              
             Assigned to:                    None => pitchumani            
                 Summary:           static_assert => add static_assert to
assert.h


    _______________________________________________________

Reply to this item at:

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

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


_______________________________________________
AVR-libc-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev
Reply | Threaded
Open this post in threaded view
|

[bug #41689] add static_assert to assert.h

Matthijs Kooijman-2
Update of bug #41689 (project avr-libc):

                  Status:               Confirmed => Fixed                  
             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up 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.

    _______________________________________________________

Reply to this item at:

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

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


_______________________________________________
AVR-libc-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev