1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 <2007> 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 <2007> 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: ANSI source including epicsMath.h won't compile with newlib 1.15 (RTEMS) |
From: | Till Straumann <[email protected]> |
To: | Eric Norum <[email protected]> |
Cc: | TECHTALK tech-talk <[email protected]> |
Date: | Tue, 18 Sep 2007 15:21:43 -0700 |
Which version of the source is this patch against?oops - I thought I had cut the diff from one level above.
Your fix obviously looks much better; I suggest you release a patch on the 'known problems' page.
The current CVS version of src/libCom/osi/os/RTEMS/epicsMath.h is now nothing but:
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
#ifndef epicsMathh #define epicsMathh
#include <math.h> #include <ieeefp.h>
#endif /* epicsMathh */
On Sep 18, 2007, at 3:00 PM, Till Straumann wrote:
libCom/osi/os/RTEMS/epicsMath.h
declares 'isnan' and 'isinf' as external functions but C99 demands that they are macros and newlib-1.15 defines them as such.
Including RTEMS' epicsMath.h from a C++ or C99 source file causes a compilation error.
The attached kludge fixes this.
In fact, using 'isnan/isinf' from code that claims to be ANSI compliant (EPICS base is usually compiled (gcc) with -ansi) is wrong. ANSI-C code should not assume these functions to be present.
-- Till
*** src/libCom/osi/os/RTEMS/epicsMath.h.orig 2007-09-18 12:38:39.000000000 -0700
--- src/libCom/osi/os/RTEMS/epicsMath.h 2007-09-18 12:46:28.000000000 -0700
***************
*** 16,24 ****
extern "C" {
#endif
int isnan(double); - int finite(double); int isinf(double);
#ifdef __cplusplus } --- 16,29 ---- extern "C" { #endif
+ /* T.S.; C99 demands that these are macros and newlib-1.15 defines + * them as such! + */ + #if defined(STRICT_ANSI) && !defined(__cplusplus) int isnan(double); int isinf(double); + #endif + int finite(double);
#ifdef __cplusplus }
--Eric Norum <[email protected]> Advanced Photon Source Argonne National Laboratory (630) 252-4793