X-Spam-Check-By: sourceware.org Message-ID: <46B0F897.6168B1BF@dessent.net> Date: Wed, 01 Aug 2007 14:18:15 -0700 From: Brian Dessent X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: missing declaration for floorl References: <147050 DOT 18700 DOT qm AT web50608 DOT mail DOT re2 DOT yahoo DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Fred Hansen wrote: > The random nubers package in http://www.agner.org/random/ uses function > floorl. It is present in the cygwin g++ library > (/lib/gcc/i686-pc-cygwin/3.4.4/libstdc++.a), but is not declared in any of > the header files (cd /usr/include; grep -rI floorl). If I declare it: > long double floorl(long double x); > then I can call it, link it, and get the correct result. > > Should math.h be augmented with the declaration of floorl? No. It's not a mistake that the definition is missing from math.h, because Cygwin does not provide this function. libstdc++ is the C++ standard library, and in general it does not implement basic libc functions like floorl, it relies on the target's C library implementation for those. And in fact the floorl that is in libstdc++ is not a real implementation of floorl, it's just a stub: #ifndef HAVE_FLOORL long double floorl(long double x) { return floor((double) x); } #endif The comment at the top of this file (libmath/stubs.c) even says: /* For targets which do not have support for long double versions, we use the crude approximation. We'll do better later. */ So it's clear that these functions are only provided as a last resort, and they aren't even fully correct implementations either since they just cast away the extra bits. And even if you added a prototype to math.h for this crude floorl(), linking would still fail on plain C source using the gcc driver, because you do not link with libstdc++ unless you use g++. So it would still be a broken implementation, but even more confusingly broken since it would appear to support something that it doesn't. No, the real problem is not that there are missing prototypes, it's that actual long double support is missing. Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/