在Visual Studio中重建我的项目时,我会在同一行错误C2371上遇到2个错误

While rebulding my project in visual studio, I am getting 2 errors on the same line error C2371

本文关键字:错误 2个 一行 C2371 遇到 重建 Studio Visual 我的 项目      更新时间:2023-10-16

1. ERROR C2556:'ULONG HTONF(float)':超载功能仅通过返回类型从'unsigned int htonf(float)' (src audiorecorder.cpp)
2.错误C2371:'htonf':重新定义;不同的基本类型(src audiorecorder.cpp)

ulong htonf(float d)
{
#ifndef __BIG_ENDIAN__
ulong a;
uchar *dst = (uchar *)&a;
uchar *src = (uchar *)&d;
dst[0] = src[3];
dst[1] = src[2];
dst[2] = src[1];
dst[3] = src[0];
return a;
#else /* really no conversion necessary, but compiler warnings =>       optimazation requried todo */
ulong a;
uchar *dst = (uchar *)&a;
uchar *src = (uchar *)&d;
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
dst[3] = src[3];
return a;
#endif
}

这是函数htonf

任何人都可以帮我吗?

您的ulong htonf(float d)与Microsofts发生冲突。每个重载函数必须具有不同的不同参数列表。

unsigned __int32 __inline htonf( float value)

https://msdn.microsoft.com/en-us/library/windows/desktop/jj710198(v = vs.85).aspx

class C {
   int func();
   double func();   // <----- error C2556
   int func(int i);   // ok parameter lists differ
};
相关文章: