[haiku-bugs] [Haiku] #7083: Guard gccisms in math.h

  • From: "kate" <trac@xxxxxxxxxxxx>
  • Date: Sun, 09 Jan 2011 20:58:05 -0000

#7083: Guard gccisms in math.h
----------------------------+------------------------
   Reporter:  kate          |       Owner:  nobody
       Type:  enhancement   |      Status:  new
   Priority:  normal        |   Milestone:  R1
  Component:  System/POSIX  |     Version:  R1/alpha2
   Keywords:                |  Blocked By:
Has a Patch:  0             |    Platform:  All
   Blocking:                |
----------------------------+------------------------
 [source:/haiku/trunk/headers/posix/math.h headers/posix/math.h] contains a
 few non-portable gccsisms. These expand out for various macros. Some have
 a guard protecting them, for if the macro is already defined.

 I propose adding similar guards around the others, so that they made be
 defined externally, and thus the file will be able to be parsed by a
 standard C compiler. Like so:
 {{{
 #!diff
 --- /boot/develop/headers/posix/math.h  2010-12-31 01:11:52.243007488
 +0000
 +++ /tmp/math.h-new     2011-01-09 11:16:01.267911168 +0000
 @@ -29,7 +29,9 @@

  #define __HUGE_VALF_v  0x7f800000L
  #define __huge_valf_t  union { unsigned char __c[4]; long __l; float __f;
 }
 -#define HUGE_VALF              (((__huge_valf_t) { __l: __HUGE_VALF_v
 }).__f)
 +#ifndef HUGE_VALF
 +#      define HUGE_VALF                (((__huge_valf_t) { __l:
 __HUGE_VALF_v }).__f)
 +#endif

  /* TODO: define HUGE_VALL for long doubles */

 }}}

 (that's not the only one; it's just an example)

 I think they could also be made standard by writing them in the C99 form,
 {{{{.a = b}}}}, but I don't know if you're targeting C99. If you do,
 please still add these guards, so the header can be still parsed with a
 C90 compiler.

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/7083>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: