error C2084: function 'float cbrt(float) throw()' already has a body - c++

I successfully complied this project under the platform of visual studio 2010,but in vs 2013 has occured these errors:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(1045) : see previous definition of 'cbrt'
d:\documents\qtprojecttest\rtsc\project4\trimesh2\include\Vec.h(657) : error C2084: function 'long double cbrt(long double) throw()' already has a body
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(1161) : see previous definition of 'cbrt'
d:\documents\qtprojecttest\rtsc\project4\trimesh2\include\Vec.h(664) : error C2084: function 'float round(float) throw()' already has a body
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(1125) : see previous definition of 'round'
d:\documents\qtprojecttest\rtsc\project4\trimesh2\include\Vec.h(672) : error C2084: function 'long double round(long double) throw()' already has a body
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(1241) : see previous definition of 'round'
d:\documents\qtprojecttest\rtsc\project4\trimesh2\include\Vec.h(679) : error C2084: function 'float trunc(float) throw()' already has a body
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(1143) : see previous definition of 'trunc'
d:\documents\qtprojecttest\rtsc\project4\trimesh2\include\Vec.h(687) : error C2084: function 'long double trunc(long double) throw()' already has a body
I want to know why there is such a difference,and how to solve it ?

why there is such a difference about VS2010 and VS2013 ? Because VS2010 doesn't have define of "cbrt",but Vs2013 have.So you can use _MSC_VER , or directly comment repeat function body in Vec.h.

Related

Iostream in Visual Studio 2015

I am a beginner c++ programmer, and have recently upgraded to windows 10 and installed the new Visual Studio 2015. However whenever I use iostream
#include <iostream>
and attempt to compile the code, it returns 289 Errors. From my understanding cmath, and math.h are conflicting with re definitions. Here is the entirety of the code in my program:
#include <iostream>
int main() {
return(0);
}
And when this is run, the output from Visual Studio 2015 is:
1>------ Build started: Project: Test, Configuration: Debug x64 ------
1> main.cpp
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(33): error C2995: '_Ty _Pow_int(_Ty,int) throw()': function template has already been defined
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1013): note: see declaration of '_Pow_int'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(36): error C2084: function 'double abs(double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1025): note: see previous definition of 'abs'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(41): error C2084: function 'double pow(double,int) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1027): note: see previous definition of 'pow'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(46): error C2084: function 'float abs(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1029): note: see previous definition of 'abs'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(51): error C2084: function 'float acos(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1031): note: see previous definition of 'acos'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(56): error C2084: function 'float acosh(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1033): note: see previous definition of 'acosh'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(61): error C2084: function 'float asin(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1035): note: see previous definition of 'asin'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(66): error C2084: function 'float asinh(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1037): note: see previous definition of 'asinh'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(71): error C2084: function 'float atan(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1039): note: see previous definition of 'atan'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(76): error C2084: function 'float atanh(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1041): note: see previous definition of 'atanh'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(81): error C2084: function 'float atan2(float,float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1043): note: see previous definition of 'atan2'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(86): error C2084: function 'float cbrt(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1045): note: see previous definition of 'cbrt'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(91): error C2084: function 'float ceil(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1047): note: see previous definition of 'ceil'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(97): error C2084: function 'float copysign(float,float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1049): note: see previous definition of 'copysign'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(102): error C2084: function 'float cos(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1051): note: see previous definition of 'cos'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(107): error C2084: function 'float cosh(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1053): note: see previous definition of 'cosh'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(112): error C2084: function 'float erf(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1055): note: see previous definition of 'erf'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(117): error C2084: function 'float erfc(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1057): note: see previous definition of 'erfc'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(122): error C2084: function 'float exp(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1059): note: see previous definition of 'exp'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(127): error C2084: function 'float exp2(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1061): note: see previous definition of 'exp2'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(132): error C2084: function 'float expm1(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1063): note: see previous definition of 'expm1'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(137): error C2084: function 'float fabs(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1065): note: see previous definition of 'fabs'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(142): error C2084: function 'float fdim(float,float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1067): note: see previous definition of 'fdim'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(147): error C2084: function 'float floor(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1069): note: see previous definition of 'floor'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(153): error C2084: function 'float fma(float,float,float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1071): note: see previous definition of 'fma'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(158): error C2084: function 'float fmax(float,float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1073): note: see previous definition of 'fmax'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(163): error C2084: function 'float fmin(float,float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1075): note: see previous definition of 'fmin'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(168): error C2084: function 'float fmod(float,float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1077): note: see previous definition of 'fmod'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(173): error C2084: function 'float frexp(float,int *) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1079): note: see previous definition of 'frexp'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(178): error C2084: function 'float hypot(float,float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1081): note: see previous definition of 'hypot'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(183): error C2084: function 'int ilogb(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1083): note: see previous definition of 'ilogb'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(188): error C2084: function 'float ldexp(float,int) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1085): note: see previous definition of 'ldexp'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(193): error C2084: function 'float lgamma(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1087): note: see previous definition of 'lgamma'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(198): error C2084: function '__int64 llrint(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1089): note: see previous definition of 'llrint'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(203): error C2084: function '__int64 llround(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1091): note: see previous definition of 'llround'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(208): error C2084: function 'float log(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1093): note: see previous definition of 'log'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(213): error C2084: function 'float log10(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1095): note: see previous definition of 'log10'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(218): error C2084: function 'float log1p(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1097): note: see previous definition of 'log1p'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(223): error C2084: function 'float log2(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1099): note: see previous definition of 'log2'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(228): error C2084: function 'float logb(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1101): note: see previous definition of 'logb'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(233): error C2084: function 'long lrint(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1103): note: see previous definition of 'lrint'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(238): error C2084: function 'long lround(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1105): note: see previous definition of 'lround'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(243): error C2084: function 'float modf(float,float *) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1107): note: see previous definition of 'modf'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(248): error C2084: function 'float nearbyint(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1109): note: see previous definition of 'nearbyint'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(253): error C2084: function 'float nextafter(float,float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1111): note: see previous definition of 'nextafter'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(259): error C2084: function 'float nexttoward(float,long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1113): note: see previous definition of 'nexttoward'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(265): error C2084: function 'float pow(float,float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1115): note: see previous definition of 'pow'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(270): error C2084: function 'float pow(float,int) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1117): note: see previous definition of 'pow'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(275): error C2084: function 'float remainder(float,float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1119): note: see previous definition of 'remainder'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(281): error C2084: function 'float remquo(float,float,int *) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1121): note: see previous definition of 'remquo'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(286): error C2084: function 'float rint(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1123): note: see previous definition of 'rint'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(291): error C2084: function 'float round(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1125): note: see previous definition of 'round'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(296): error C2084: function 'float scalbln(float,long) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1127): note: see previous definition of 'scalbln'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(301): error C2084: function 'float scalbn(float,int) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1129): note: see previous definition of 'scalbn'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(306): error C2084: function 'float sin(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1131): note: see previous definition of 'sin'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(311): error C2084: function 'float sinh(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1133): note: see previous definition of 'sinh'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(316): error C2084: function 'float sqrt(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1135): note: see previous definition of 'sqrt'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(321): error C2084: function 'float tan(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1137): note: see previous definition of 'tan'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(326): error C2084: function 'float tanh(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1139): note: see previous definition of 'tanh'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(331): error C2084: function 'float tgamma(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1141): note: see previous definition of 'tgamma'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(336): error C2084: function 'float trunc(float) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1143): note: see previous definition of 'trunc'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(341): error C2084: function 'long double abs(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1145): note: see previous definition of 'abs'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(346): error C2084: function 'long double acos(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1147): note: see previous definition of 'acos'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(351): error C2084: function 'long double acosh(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1149): note: see previous definition of 'acosh'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(356): error C2084: function 'long double asin(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1151): note: see previous definition of 'asin'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(361): error C2084: function 'long double asinh(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1153): note: see previous definition of 'asinh'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(366): error C2084: function 'long double atan(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1155): note: see previous definition of 'atan'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(371): error C2084: function 'long double atanh(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1157): note: see previous definition of 'atanh'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(377): error C2084: function 'long double atan2(long double,long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1159): note: see previous definition of 'atan2'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(382): error C2084: function 'long double cbrt(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1161): note: see previous definition of 'cbrt'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(387): error C2084: function 'long double ceil(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1163): note: see previous definition of 'ceil'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(393): error C2084: function 'long double copysign(long double,long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1165): note: see previous definition of 'copysign'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(398): error C2084: function 'long double cos(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1167): note: see previous definition of 'cos'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(403): error C2084: function 'long double cosh(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1169): note: see previous definition of 'cosh'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(408): error C2084: function 'long double erf(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1171): note: see previous definition of 'erf'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(413): error C2084: function 'long double erfc(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1173): note: see previous definition of 'erfc'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(418): error C2084: function 'long double exp(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1175): note: see previous definition of 'exp'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(423): error C2084: function 'long double exp2(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1177): note: see previous definition of 'exp2'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(428): error C2084: function 'long double expm1(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1179): note: see previous definition of 'expm1'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(433): error C2084: function 'long double fabs(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1181): note: see previous definition of 'fabs'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(439): error C2084: function 'long double fdim(long double,long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1183): note: see previous definition of 'fdim'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(444): error C2084: function 'long double floor(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1185): note: see previous definition of 'floor'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(450): error C2084: function 'long double fma(long double,long double,long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1187): note: see previous definition of 'fma'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(456): error C2084: function 'long double fmax(long double,long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1189): note: see previous definition of 'fmax'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(462): error C2084: function 'long double fmin(long double,long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1191): note: see previous definition of 'fmin'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(468): error C2084: function 'long double fmod(long double,long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1193): note: see previous definition of 'fmod'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(474): error C2084: function 'long double frexp(long double,int *) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1195): note: see previous definition of 'frexp'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(480): error C2084: function 'long double hypot(long double,long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1197): note: see previous definition of 'hypot'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(485): error C2084: function 'int ilogb(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1199): note: see previous definition of 'ilogb'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(491): error C2084: function 'long double ldexp(long double,int) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1201): note: see previous definition of 'ldexp'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(496): error C2084: function 'long double lgamma(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1203): note: see previous definition of 'lgamma'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(501): error C2084: function '__int64 llrint(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1205): note: see previous definition of 'llrint'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(506): error C2084: function '__int64 llround(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1207): note: see previous definition of 'llround'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(511): error C2084: function 'long double log(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1209): note: see previous definition of 'log'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(516): error C2084: function 'long double log10(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1211): note: see previous definition of 'log10'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(521): error C2084: function 'long double log1p(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1213): note: see previous definition of 'log1p'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(526): error C2084: function 'long double log2(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1215): note: see previous definition of 'log2'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(531): error C2084: function 'long double logb(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1217): note: see previous definition of 'logb'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(536): error C2084: function 'long lrint(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1219): note: see previous definition of 'lrint'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(541): error C2084: function 'long lround(long double) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1221): note: see previous definition of 'lround'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(547): error C2084: function 'long double modf(long double,long double *) throw()' already has a body
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\math.h(1223): note: see previous definition of 'modf'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\cmath(547): fatal error C1003: error count exceeds 100; stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I would appreciate if anyone had suggestions for how to resolve this problem.
Thanks for any help.
Your toolchain is completely broken. I suggest removing then re-installing Visual Studio.

glog on visual studio 2015

I am trying to build Google glog library on windows using Visual Studio 2015. After adding #include to get around the std::min problem on Windows, I get to 2 main errors (1 repeats a few times) below.
1>c:\glog\glog-0.3.3\src\windows\port.h(117): warning C4005: 'va_copy': macro redefinition
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\stdarg.h(20): note: see previous definition of 'va_copy'
1>c:\glog\glog-0.3.3\src\windows\port.cc(58): error C2084: function 'int snprintf(char *const ,const size_t,const char *const ,...)' already has a body
1> c:\program files (x86)\windows kits\10\include\10.0.10150.0\ucrt\stdio.h(1932): note: see previous definition of 'snprintf'
1> vlog_is_on.cc
1>c:\glog\glog-0.3.3\src\windows\port.h(117): warning C4005: 'va_copy': macro redefinition
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\stdarg.h(20): note: see previous definition of 'va_copy'
1>c:\glog\glog-0.3.3\src\windows\glog\logging.h(1266): error C2280: 'std::basic_ios<char,std::char_traits<char>>::basic_ios(const std::basic_ios<char,std::char_traits<char>> &)': attempting to reference a deleted function
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\ios(189): note: see declaration of 'std::basic_ios<char,std::char_traits<char>>::basic_ios'
1> c:\glog\glog-0.3.3\src\windows\glog\logging.h(1266): note: This diagnostic occurred in the compiler generated function 'google::LogMessage::LogStream::LogStream(google::LogMessage::LogStream &&)'
1> utilities.cc
Seems to be an issue with the compiler generated move function, but explicitly deleting it does not work either.
LogMessage(const LogMessage&&) = delete;
Any ideas?
Cheers, Mike
The generated function is not LogMessage(const LogMessage&&) = delete;
but it is:
LogStream::LogStream(google::LogMessage::LogStream &&).
Internaly it will try to call the copy constructor of LogStream and hence the ostream which is marked as deleted.
Solution:
declare inside LogStream class:
LogStream(const LogStream&) = delete;
LogStream& operator=(const LogStream&) = delete;;
Cheers

How to use std::for_each with a member function, where the provided data structure gives the parameter and not object

I cannot use C++11.
Normally when using std::for_each with a member function, the provided data structure gives the object on which the bound member function is called. However, I would like to know if it's possible to provide my own object which is constant throughout the loop, and use the data structure for the parameters to this member function.
Here is an example of what I want to do.
std::string GenerateKey(const std::vector<std::string>& parameters)
{
std::string key;
key.reserve(std::accumulate(parameters.begin(), parameters.end(), 0, std::mem_fun_ref(&std::string::length)));
std::for_each(parameters.begin(), parameters.end(), std::bind1st(std::mem_fun_ref(&std::string::append), key));
return key;
}
The intention is that for each string in parameters, append will be called on key, and be passed a string from parameters.
Why does this std::for_each not work, and how or can it be made to work?
I know there are alternative ways to concatenate strings. I want to understand C++ functional programming better.
Thanks.
Here are error messages from VS2013, which I doubt will help..
generator.cpp(28): error C2784: 'std::const_mem_fun1_ref_t<_Result,_Ty,_Arg> std::mem_fun_ref(_Result (__thiscall _Ty::* )(_Arg) const)' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(910) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(910) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(910) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(910) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(910) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(910) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(910) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(910) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2783: 'std::const_mem_fun1_ref_t<_Result,_Ty,_Arg> std::mem_fun_ref(_Result (__thiscall _Ty::* )(_Arg) const)' : could not deduce template argument for '_Result'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(910) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2783: 'std::const_mem_fun1_ref_t<_Result,_Ty,_Arg> std::mem_fun_ref(_Result (__thiscall _Ty::* )(_Arg) const)' : could not deduce template argument for '_Ty'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(910) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2783: 'std::const_mem_fun1_ref_t<_Result,_Ty,_Arg> std::mem_fun_ref(_Result (__thiscall _Ty::* )(_Arg) const)' : could not deduce template argument for '_Arg'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(910) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2784: 'std::const_mem_fun_ref_t<_Result,_Ty> std::mem_fun_ref(_Result (__thiscall _Ty::* )(void) const)' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(901) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(901) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(901) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(901) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(901) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(901) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(901) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(901) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2783: 'std::const_mem_fun_ref_t<_Result,_Ty> std::mem_fun_ref(_Result (__thiscall _Ty::* )(void) const)' : could not deduce template argument for '_Result'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(901) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2783: 'std::const_mem_fun_ref_t<_Result,_Ty> std::mem_fun_ref(_Result (__thiscall _Ty::* )(void) const)' : could not deduce template argument for '_Ty'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(901) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2784: 'std::mem_fun1_ref_t<_Result,_Ty,_Arg> std::mem_fun_ref(_Result (__thiscall _Ty::* )(_Arg))' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(893) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(893) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(893) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(893) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(893) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2914: 'std::mem_fun_ref' : cannot deduce template argument as function argument is ambiguous
generator.cpp(28): error C2783: 'std::mem_fun1_ref_t<_Result,_Ty,_Arg> std::mem_fun_ref(_Result (__thiscall _Ty::* )(_Arg))' : could not deduce template argument for '_Result'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(893) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2783: 'std::mem_fun1_ref_t<_Result,_Ty,_Arg> std::mem_fun_ref(_Result (__thiscall _Ty::* )(_Arg))' : could not deduce template argument for '_Ty'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(893) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2783: 'std::mem_fun1_ref_t<_Result,_Ty,_Arg> std::mem_fun_ref(_Result (__thiscall _Ty::* )(_Arg))' : could not deduce template argument for '_Arg'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(893) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2784: 'std::mem_fun_ref_t<_Result,_Ty> std::mem_fun_ref(_Result (__thiscall _Ty::* )(void))' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(884) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(884) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(884) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(884) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(884) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(884) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(884) : see declaration of 'std::mem_fun_ref'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(884) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2783: 'std::mem_fun_ref_t<_Result,_Ty> std::mem_fun_ref(_Result (__thiscall _Ty::* )(void))' : could not deduce template argument for '_Result'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(884) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2783: 'std::mem_fun_ref_t<_Result,_Ty> std::mem_fun_ref(_Result (__thiscall _Ty::* )(void))' : could not deduce template argument for '_Ty'
c:\program files\microsoft visual studio 12.0\vc\include\xfunctional(884) : see declaration of 'std::mem_fun_ref'
generator.cpp(28): error C2780: '_Fn1 std::for_each(_InIt,_InIt,_Fn1)' : expects 3 arguments - 2 provided
c:\program files\microsoft visual studio 12.0\vc\include\algorithm(29) : see declaration of 'std::for_each'
std::string::append is overloaded and the compiler is unable to know which function you meant.
So, std::string::append actually refers to a set of functions.
This error there because there are some of overloaded versions function std::string::append, you can use cast to tell compiler what exacly function need to use:
std::for_each(parameters.begin(), parameters.end(), std::bind1st(std::mem_fun_ref(static_cast<std::string& (std::string::*)(const std::string&)>(&std::string::append)), key));
Edit: but in this case it won't be worked, because bind1st will not work with functions, that takes references as parameter.
See: Using bind1st for a method that takes argument by reference

Why won't this code compile and run in Visual Studio 2010?

I am trying to get Visual Studio 2010 set up to do plain old ANSI compilation, without Microsoft extensions of any kind.
I started with an empty project template, since there doesn't seem to be a plain ANSI project template in 2010 anymore.
Then I set
Properties -> Configuration Properties -> C/C++ -> Language -> Disable Extensions = Yes (/Za)
Here is my code:
#include <iostream>
int main( int argc, const char* argv[] )
{
std::cout << "Hello World!";
return 0;
}
Here are the errors:
1>------ Build started: Project: ansi_test, Configuration: Release Win32 ------
1>Build started 4/27/2011 4:20:00 PM.
1>InitializeBuildStatus:
1> Touching "Release\ansi_test.unsuccessfulbuild".
1>ClCompile:
1> Main.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(636): error C3861: 'width': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(636): error C3861: 'width': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(639): error C3861: 'flags': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(643): error C2227: left of '->sputc' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(643): error C2780: 'void std::fill(_FwdIt,_FwdIt,const _Ty &)' : expects 3 arguments - 0 provided
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(2712) : see declaration of 'std::fill'
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(643): error C3861: 'rdbuf': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(648): error C2227: left of '->sputc' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(648): error C3861: 'rdbuf': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(654): error C2227: left of '->sputc' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(654): error C2780: 'void std::fill(_FwdIt,_FwdIt,const _Ty &)' : expects 3 arguments - 0 provided
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(2712) : see declaration of 'std::fill'
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(654): error C3861: 'rdbuf': identifier not found
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(659): error C3861: 'width': identifier not found
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.63
How do I get this, the most basic of C++ code to compile cleanly?
The error disappears if you define wchar_t as native type.
If I copy your code into a file, test.cpp and then issue the command
cl /Za /EHsc test.cpp
then it compiles cleanly without any warnings or errors on my install of visual c++ express 2010. /EHsc is necessary in order to handle exceptions properly and I don't really understand why it isn't the default.
Is this different from what you are doing?

VS2005 C++ compiler problem including <comdef.h> in MFC application

I am having some trouble converting an old project from VS6 to VS2005. At one place in the code it uses the type variant_t so it includes comdef.h for this purpose. comdef.h then includes comutil.h which generates these errors for me:
c:\program files\microsoft visual studio 8\vc\include\comutil.h(978) : error C2535: '_variant_t::_variant_t(int) throw()' : member function already defined or declared
c:\program files\microsoft visual studio 8\vc\include\comutil.h(970) : see declaration of '_variant_t::_variant_t'
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1007) : error C2535: '_variant_t::operator int(void) const' : member function already defined or declared
c:\program files\microsoft visual studio 8\vc\include\comutil.h(998) : see declaration of '_variant_t::operator int'
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1037) : error C2535: '_variant_t &_variant_t::operator =(int)' : member function already defined or declared
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1029) : see declaration of '_variant_t::operator ='
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1331) : error C2084: function '_variant_t::_variant_t(int) throw()' already has a body
c:\program files\microsoft visual studio 8\vc\include\comutil.h(970) : see previous definition of '{ctor}'
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1588) : error C2084: function '_variant_t::operator int(void) const' already has a body
c:\program files\microsoft visual studio 8\vc\include\comutil.h(998) : see previous definition of '.H'
c:\program files\microsoft visual studio 8\vc\include\comutil.h(2006) : error C2084: function '_variant_t &_variant_t::operator =(int)' already has a body
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1029) : see previous definition of '='
There is probably some configuration that is incorrect, some define missing or some include file I should have included but I can't seem to find the problem. Any pointers in the right direction is much appreciated
This looks like one of two things, an include order problem or as you stated something not getting defined but I am leaning towards the first one. You might want to check msdn and make sure there are no restrictions on when comutil.h can be included (I know this is an issue if you include winsock2.h before windows.h). There is also an option under C/C++ > Advanced to Show Includes (/showIncludes option from the command-line) which is generally helpful when trying to track issues like this down.
Does your own code do something like this:
#define long int