On Fri, Jun 20, 2008 at 2:17 PM, Jürgen Krämer <[EMAIL PROTECTED]> wrote:

> Hi,
>
> Patrick Texier wrote:
>> Le Fri, 20 Jun 2008 11:37:51 +0200, Bram Moolenaar a écrit dans le
>> message <[EMAIL PROTECTED]> :
>>
>>> I have made a few more improvements:
>>
>> Thanks Bram.
>>
>> Using Borland C++ 5.5 (HUGE with FLOAT), I had the following warnings :
>>
>> .\eval.c:
>> Warning W8065 .\eval.c 14642: Call to function 'round' with no prototype
>> in function f_round
>> Warning W8065 .\eval.c 17027: Call to function 'trunc' with no prototype
>> in function f_trunc
>>
>> And a linker error :
>>
>> Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
>> Error: Unresolved external '_round' referenced from 
>> C:\SRC\VIM71\SRC\WIN32\OLEOB
>> J\EVAL.OBJ
>> Error: Unresolved external '_trunc' referenced from 
>> C:\SRC\VIM71\SRC\WIN32\OLEOB
>> J\EVAL.OBJ
>
> I'm not absolutely sure, but I think round() and trunc() are not part of
> the standard C runtime library.
>
> As a workaround in eval.c you can simply replace
>        rettv->vval.v_float = round(f);
> with
>        rettv->vval.v_float = ceil(f + 0.5);
> and
>        rettv->vval.v_float = trunc(f);
> with
>        rettv->vval.v_float = ceil(f);
>
> You can also find two calls to both round() and trunc() in
> src/auto/configure. As you compile with Borland C++ you can ignore those
> -- if you want you can safely delete them (I think).
>
> Regards,
> Jürgen


round() and trunc() are not very portable.

floor() should be portable and we can easily implement
a portable version of round() from floor() with:

/*
 * Portable version of round()
 *
 * 1.4 -> 1.0
 * 1.6 -> 2.0
 * -1.4 -> -1.0
 * -1.6 -> -2.0
 */
double portable_round(double d)
{
  return floor(d + 0.5);
}

-- Dominique

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to