用C ceil函数的实现 [英] Implementation of ceil function in C

查看:762
本文介绍了用C ceil函数的实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于 CEIL两个问题()功能..

I have two questions regarding ceil() function..


  1. CEIL()函数是用C实现的如果我使用 CEIL(3/2),它工作正常。但是当我使用 CEIL(数/ 2),如果计数值为3,那么它给了编译时错误。

  1. The ceil() function is implemented in C. If I use ceil(3/2), it works fine. But when I use ceil(count/2), if value of count is 3, then it gives compile time error.

/tmp/ccA4Yj7p.o(+的.text 0x364):在功能上 FrontBackSplit':未定义引用 CEIL'collect2:LD返回1退出状态。

/tmp/ccA4Yj7p.o(.text+0x364): In function FrontBackSplit': : undefined reference toceil' collect2: ld returned 1 exit status

如何使用第二种情况下,ceil函数?请建议。

How to use the ceil function in second case? Please suggest.

我怎样才能实现C.我自己ceil函数请给一些基本准则。

How can I implement my own ceil function in C. Please give some basic guidelines.

感谢。

推荐答案

CEIL()函数在数学库, libm中实现的。所以。默认情况下,链接器不会对这个库在通过gcc后调用链接。要链接针对库,通过 -lm 在命令行上的GCC:

The ceil() function is implemented in the math library, libm.so. By default, the linker does not link against this library when invoked via the gcc frontend. To link against that library, pass -lm on the command line to gcc:

gcc main.c -lm

这篇关于用C ceil函数的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆