图形学吧 关注:269贴子:257
  • 0回复贴,共1

大虾,这个错误怎么fix???

只看楼主收藏回复

源代码:
//DDA算法
#include <stdlib.h>
#include <math.h>
inline int round(const float a) { return int(a + 0.5); }
void lineDDA(int x0,int y0,int xEnd, int yEnd)
{
int dx = xEnd - x0, dy = yEnd - y0, steps, k;
float xIncrement, yIncrement, x = x0, y = y0;
if (fabs(dx) > fabs(dy))
steps = fabs(dx);
else
steps = fabs(dy);
xIncrement = float(dx) / float(steps);
yIncrement = float(dy) / float(steps);
setPixel(round(x), round(y));
for (k = 0; k < steps; k++)
{
x += xIncrement;
y += yIncrement;
setPixel(round(x), round(y));
}
}
错误信息:
1>------ Build started: Project: 计算机图形学, Configuration: Debug Win32 ------
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(381,5): warning MSB8028: The intermediate directory (Debug\) contains files shared from another project (Win32Project1.vcxproj). This can lead to incorrect clean and rebuild behavior.
1> 3.5.2 DDA算法.cpp
1>3.5.2 DDA算法.cpp(5): error C2556: 'int round(const float)' : overloaded function differs only by return type from 'float round(float) throw()'
1> C:\Program Files\Microsoft Visual Studio 12.0\VC\include\math.h(1125) : see declaration of 'round'
1>3.5.2 DDA算法.cpp(5): error C2371: 'round' : redefinition; different basic types
1> C:\Program Files\Microsoft Visual Studio 12.0\VC\include\math.h(1125) : see declaration of 'round'
1>3.5.2 DDA算法.cpp(10): warning C4244: 'initializing' : conversion from 'int' to 'float', possible loss of data
1>3.5.2 DDA算法.cpp(11): error C2668: 'fabs' : ambiguous call to overloaded function
1> C:\Program Files\Microsoft Visual Studio 12.0\VC\include\math.h(1181): could be 'long double fabs(long double) throw()'
1> C:\Program Files\Microsoft Visual Studio 12.0\VC\include\math.h(1065): or 'float fabs(float) throw()'
1> C:\Program Files\Microsoft Visual Studio 12.0\VC\include\math.h(491): or 'double fabs(double)'
1> while trying to match the argument list '(int)'
1>3.5.2 DDA算法.cpp(12): error C2668: 'fabs' : ambiguous call to overloaded function
1> C:\Program Files\Microsoft Visual Studio 12.0\VC\include\math.h(1181): could be 'long double fabs(long double) throw()'
1> C:\Program Files\Microsoft Visual Studio 12.0\VC\include\math.h(1065): or 'float fabs(float) throw()'
1> C:\Program Files\Microsoft Visual Studio 12.0\VC\include\math.h(491): or 'double fabs(double)'
1> while trying to match the argument list '(int)'
1>3.5.2 DDA算法.cpp(14): error C2668: 'fabs' : ambiguous call to overloaded function
1> C:\Program Files\Microsoft Visual Studio 12.0\VC\include\math.h(1181): could be 'long double fabs(long double) throw()'
1> C:\Program Files\Microsoft Visual Studio 12.0\VC\include\math.h(1065): or 'float fabs(float) throw()'
1> C:\Program Files\Microsoft Visual Studio 12.0\VC\include\math.h(491): or 'double fabs(double)'
1> while trying to match the argument list '(int)'
1>3.5.2 DDA算法.cpp(18): error C2264: 'round' : error in function definition or declaration; function not called
1>3.5.2 DDA算法.cpp(18): error C3861: 'setPixel': identifier not found
1>3.5.2 DDA算法.cpp(23): error C2264: 'round' : error in function definition or declaration; function not called
1>3.5.2 DDA算法.cpp(23): error C3861: 'setPixel': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


IP属地:广西1楼2014-06-13 10:42回复