[問題]有關 round() 的問題
看板C_and_CPP (C/C++)作者watson1988 (watson)時間12年前 (2013/10/03 17:45)推噓0(0推 0噓 12→)留言12則, 2人參與討論串1/2 (看更多)
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++ 6.0
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
宣告
#include "main.h"
#include <time.h> //time_t time() clock_t clock()
#include <Mmsystem.h> //timeGetTime()
#pragma comment(lib, "Winmm.lib") //timeGetTime()
#include <math.h>
#define Round(x) ((x)-(int)(x))>=0.5?ceil((x)):floor((x))
以下進行例行性的程序
SetPulse=round((111.11111*iParam7));
printf("SetPulse=%d\n",SetPulse);
for(i=0 ;i<iParam3 ;i++)
{ Sleep(100);
for( j = 1 ; j<=10 ; j++)
{
HW_SetPositionPulse(2,SetPulse);
HW_SetPositionPulse(3,SetPulse);
}
}
我的compile有過
但是再build的時候出現了
Linking...
Main.obj : error LNK2001: unresolved external symbol _round
Debug_GMC700K/GMC700K.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Creating browse info file...
GMC700K.exe - 2 error(s), 0 warning(s)
我找不太到原因出在哪
四捨五入還有其他更簡單的寫法嗎!?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.124.249.111
※ 編輯: watson1988 來自: 140.124.249.111 (10/03 17:51)
→
10/03 17:51, , 1F
10/03 17:51, 1F
→
10/03 17:53, , 2F
10/03 17:53, 2F
→
10/03 17:55, , 3F
10/03 17:55, 3F
→
10/03 17:56, , 4F
10/03 17:56, 4F
→
10/03 17:59, , 5F
10/03 17:59, 5F
→
10/03 18:19, , 6F
10/03 18:19, 6F
→
10/03 18:23, , 7F
10/03 18:23, 7F
→
10/03 18:33, , 8F
10/03 18:33, 8F
換成下面這一行嗎?!
#define ROUND(x) (int)((x) + 0.5 - (double)((x) < 0))
※ 編輯: watson1988 來自: 140.124.249.111 (10/03 18:38)
→
10/03 18:38, , 9F
10/03 18:38, 9F
→
10/03 18:41, , 10F
10/03 18:41, 10F
→
10/03 18:43, , 11F
10/03 18:43, 11F
→
10/03 18:44, , 12F
10/03 18:44, 12F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
0
12
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章