error C2668: 'abs' : ambiguous call to overloaded function
boost version 2002-01-02
VC 7.1 Final Beta
"error C2668: 'abs' : ambiguous call to overloaded function" when compile
following code. The same code can be built successfully in vc6.
Any suggestion are appreciated.
#define DATE_TIME_INLINE
#define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
#include <iostream>
#include <string>
using namespace std;
#include
Black Ice wrote:
boost version 2002-01-02 VC 7.1 Final Beta "error C2668: 'abs' : ambiguous call to overloaded function" when compile following code. The same code can be built successfully in vc6. Any suggestion are appreciated.
#define DATE_TIME_INLINE #define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
#include <iostream> #include <string> using namespace std;
#include
#include using namespace boost::gregorian; using namespace boost::posix_time;
void testDateTime2() { date d(2002, Nov, 1); //an arbitrary date ptime t1(d, hours(5) + nanosec(100));//date + time of day offset ptime t2 = t1 - minutes(4)+seconds(2); ptime now = second_clock::local_time(); //use the clock //Get the date part out of the time date today = now.date(); date tommorrow = today + date_duration(1); ptime tommorrow_start(tommorrow); //midnight
cout << "d is " << to_iso_extended_string(d) << endl; cout << "t1 is " << to_iso_extended_string(t1) << endl; cout << "t2 is " << to_iso_extended_string(t2) << endl; cout << "now is " << to_iso_extended_string(now) << endl; cout << "today is " << to_iso_extended_string(today) << endl; cout << "tommorrow is " << to_iso_extended_string(tommorrow) << endl; cout << "tommorrow_start is " << to_iso_extended_string(tommorrow_start) << endl;
//starting at current time iterator adds by one hour time_iterator titr(now,hours(1)); for (; titr < tommorrow_start; ++titr) { cout << to_iso_extended_string(*titr) << endl; } }
-- /*******************/ ×ÔÓÉ£¨liberty£©Î޷ǾÍÊÇÕâÑùÒ»ÖÖ³Ðŵ£ºÃ¿¸öÈ˽«»áµÃµ½Ò»ÖÖ±£ÕÏ£¬±£ÕÏÎÒÃÇ¿ÉÒÔÓë ȨÍþ¡¢¶àÊý¡¢Á÷Ë×¼°ÓßÂÛµÄÓ°ÏìÏ࿹ºâ¡£ /*******************/
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
'abs' ambiguious error is because you opened up the std namespace via the line 'using std namespace'. I've found numerous similiar problems when I do the same.
--- In Boost-Users@yahoogroups.com, "Black Ice" wrote:
boost version 2002-01-02 VC 7.1 Final Beta "error C2668: 'abs' : ambiguous call to overloaded function" when compile following code. The same code can be built successfully in vc6. Any suggestion are appreciated.
I suggest ... that you tell us which line caused the error. Also, if you really need the using declaration for namespace std, try putting it after all the includes. Otherwise you're messing with the context of the included files.
#define DATE_TIME_INLINE #define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
#include <iostream> #include <string> using namespace std;
^^^^^^^^^^^^^^^^^^^ <- move this
#include
#include
using namespace std; // <- to here
using namespace boost::gregorian; using namespace boost::posix_time;
<snip>
After I move the line 'using std namespace', the error still occurs.
The error occurs in file date_time/time_duration.hpp, line 66.
min_type minutes() const
{
return std::abs(((ticks() / (60*rep_type::res_adjust())) % 60));
}
--
/*******************/
×ÔÓÉ£šliberty£©ÎÞ·ÇŸÍÊÇÕâÑùÒ»ÖÖ³Ðŵ£ºÃ¿žöÈËœ«»áµÃµœÒ»ÖÖ±£ÕÏ£¬±£ÕÏÎÒÃÇ¿ÉÒÔÓë
ÈšÍþ¡¢¶àÊý¡¢Á÷Ë׌°ÓßÂÛµÄÓ°ÏìÏ࿹ºâ¡£
/*******************/
"Black Ice"
boost version 2002-01-02 VC 7.1 Final Beta "error C2668: 'abs' : ambiguous call to overloaded function" when compile following code. The same code can be built successfully in vc6. Any suggestion are appreciated.
#define DATE_TIME_INLINE #define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
#include <iostream> #include <string> using namespace std;
#include
#include using namespace boost::gregorian; using namespace boost::posix_time;
void testDateTime2() { date d(2002, Nov, 1); //an arbitrary date ptime t1(d, hours(5) + nanosec(100));//date + time of day offset ptime t2 = t1 - minutes(4)+seconds(2); ptime now = second_clock::local_time(); //use the clock //Get the date part out of the time date today = now.date(); date tommorrow = today + date_duration(1); ptime tommorrow_start(tommorrow); //midnight
cout << "d is " << to_iso_extended_string(d) << endl; cout << "t1 is " << to_iso_extended_string(t1) << endl; cout << "t2 is " << to_iso_extended_string(t2) << endl; cout << "now is " << to_iso_extended_string(now) << endl; cout << "today is " << to_iso_extended_string(today) << endl; cout << "tommorrow is " << to_iso_extended_string(tommorrow) << endl; cout << "tommorrow_start is " << to_iso_extended_string(tommorrow_start) << endl;
//starting at current time iterator adds by one hour time_iterator titr(now,hours(1)); for (; titr < tommorrow_start; ++titr) { cout << to_iso_extended_string(*titr) << endl; } }
-- /*******************/ ×ÔÓÉ£šliberty£©ÎÞ·ÇŸÍÊÇÕâÑùÒ»ÖÖ³Ðŵ£ºÃ¿žöÈËœ«»áµÃµœÒ»ÖÖ±£ÕÏ£¬±£ÕÏÎÒÃÇ¿ÉÒÔ Óë ÈšÍþ¡¢¶àÊý¡¢Á÷Ë׌°ÓßÂÛµÄÓ°ÏìÏ࿹ºâ¡£ /*******************/
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Can I assume it's a bug of boost.date_time?
--
/*******************/
×ÔÓÉ£šliberty£©ÎÞ·ÇŸÍÊÇÕâÑùÒ»ÖÖ³Ðŵ£ºÃ¿žöÈËœ«»áµÃµœÒ»ÖÖ±£ÕÏ£¬±£ÕÏÎÒÃÇ¿ÉÒÔÓë
ÈšÍþ¡¢¶àÊý¡¢Á÷Ë׌°ÓßÂÛµÄÓ°ÏìÏ࿹ºâ¡£
/*******************/
"Black Ice"
After I move the line 'using std namespace', the error still occurs. The error occurs in file date_time/time_duration.hpp, line 66. min_type minutes() const { return std::abs(((ticks() / (60*rep_type::res_adjust())) % 60)); }
-- /*******************/ ×ÔÓÉ£šliberty£©ÎÞ·ÇŸÍÊÇÕâÑùÒ»ÖÖ³Ðŵ£ºÃ¿žöÈËœ«»áµÃµœÒ»ÖÖ±£ÕÏ£¬±£ÕÏÎÒÃÇ¿ÉÒÔ Óë ÈšÍþ¡¢¶àÊý¡¢Á÷Ë׌°ÓßÂÛµÄÓ°ÏìÏ࿹ºâ¡£ /*******************/
"Black Ice"
ÐŽÈëÏûÏ¢ÐÂÎÅ :av2tmo$42o$1@main.gmane.org... boost version 2002-01-02 VC 7.1 Final Beta "error C2668: 'abs' : ambiguous call to overloaded function" when compile following code. The same code can be built successfully in vc6. Any suggestion are appreciated.
#define DATE_TIME_INLINE #define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
#include <iostream> #include <string> using namespace std;
#include
#include using namespace boost::gregorian; using namespace boost::posix_time;
void testDateTime2() { date d(2002, Nov, 1); //an arbitrary date ptime t1(d, hours(5) + nanosec(100));//date + time of day offset ptime t2 = t1 - minutes(4)+seconds(2); ptime now = second_clock::local_time(); //use the clock //Get the date part out of the time date today = now.date(); date tommorrow = today + date_duration(1); ptime tommorrow_start(tommorrow); //midnight
cout << "d is " << to_iso_extended_string(d) << endl; cout << "t1 is " << to_iso_extended_string(t1) << endl; cout << "t2 is " << to_iso_extended_string(t2) << endl; cout << "now is " << to_iso_extended_string(now) << endl; cout << "today is " << to_iso_extended_string(today) << endl; cout << "tommorrow is " << to_iso_extended_string(tommorrow) << endl; cout << "tommorrow_start is " << to_iso_extended_string(tommorrow_start) << endl;
//starting at current time iterator adds by one hour time_iterator titr(now,hours(1)); for (; titr < tommorrow_start; ++titr) { cout << to_iso_extended_string(*titr) << endl; } }
-- /*******************/ ×ÔÓÉ£šliberty£©ÎÞ·ÇŸÍÊÇÕâÑùÒ»ÖÖ³Ðŵ£ºÃ¿žöÈËœ«»áµÃµœÒ»ÖÖ±£ÕÏ£¬±£ÕÏÎÒÃÇ¿É ÒÔ Óë ÈšÍþ¡¢¶àÊý¡¢Á÷Ë׌°ÓßÂÛµÄÓ°ÏìÏ࿹ºâ¡£ /*******************/
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
On Friday, January 3, 2003, at 10:34 PM, Black Ice wrote:
Can I assume it's a bug of boost.date_time?
No.
using namespace std;
#include
#include
The above code has an error. You must not do a "using namespace" before including a header file and expect that to work. I recommend that you move the using namespace directives so they are all below all your includes. -- Darin
But I has remove the line "using namespace std";
--
/*******************/
×ÔÓÉ£šliberty£©ÎÞ·ÇŸÍÊÇÕâÑùÒ»ÖÖ³Ðŵ£ºÃ¿žöÈËœ«»áµÃµœÒ»ÖÖ±£ÕÏ£¬±£ÕÏÎÒÃÇ¿ÉÒÔÓë
ÈšÍþ¡¢¶àÊý¡¢Á÷Ë׌°ÓßÂÛµÄÓ°ÏìÏ࿹ºâ¡£
/*******************/
"Darin Adler"
On Friday, January 3, 2003, at 10:34 PM, Black Ice wrote:
Can I assume it's a bug of boost.date_time?
No.
using namespace std;
#include
#include The above code has an error. You must not do a "using namespace" before including a header file and expect that to work.
I recommend that you move the using namespace directives so they are all below all your includes.
-- Darin
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Detail error message:
d:\boost\boost\boost\date_time\time_duration.hpp(66) : error C2668: 'abs' :
ambiguous call to overloaded function
d:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\math.h(528): could be 'long abs(long)'
d:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\math.h(530): or 'double abs(double)'
d:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\math.h(536): or 'float abs(float)'
d:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\math.h(584): or 'long double abs(long double)'
d:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\stdlib.h(265): or 'int abs(int)'
while trying to match the argument list
'(boost::date_time::time_resolution_traits
After I move the line 'using std namespace', the error still occurs. The error occurs in file date_time/time_duration.hpp, line 66. min_type minutes() const { return std::abs(((ticks() / (60*rep_type::res_adjust())) % 60)); }
-- /*******************/ ×ÔÓÉ£šliberty£©ÎÞ·ÇŸÍÊÇÕâÑùÒ»ÖÖ³Ðŵ£ºÃ¿žöÈËœ«»áµÃµœÒ»ÖÖ±£ÕÏ£¬±£ÕÏÎÒÃÇ¿ÉÒÔ Óë ÈšÍþ¡¢¶àÊý¡¢Á÷Ë׌°ÓßÂÛµÄÓ°ÏìÏ࿹ºâ¡£ /*******************/
"Black Ice"
ÐŽÈëÏûÏ¢ÐÂÎÅ :av2tmo$42o$1@main.gmane.org... boost version 2002-01-02 VC 7.1 Final Beta "error C2668: 'abs' : ambiguous call to overloaded function" when compile following code. The same code can be built successfully in vc6. Any suggestion are appreciated.
#define DATE_TIME_INLINE #define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
#include <iostream> #include <string> using namespace std;
#include
#include using namespace boost::gregorian; using namespace boost::posix_time;
void testDateTime2() { date d(2002, Nov, 1); //an arbitrary date ptime t1(d, hours(5) + nanosec(100));//date + time of day offset ptime t2 = t1 - minutes(4)+seconds(2); ptime now = second_clock::local_time(); //use the clock //Get the date part out of the time date today = now.date(); date tommorrow = today + date_duration(1); ptime tommorrow_start(tommorrow); //midnight
cout << "d is " << to_iso_extended_string(d) << endl; cout << "t1 is " << to_iso_extended_string(t1) << endl; cout << "t2 is " << to_iso_extended_string(t2) << endl; cout << "now is " << to_iso_extended_string(now) << endl; cout << "today is " << to_iso_extended_string(today) << endl; cout << "tommorrow is " << to_iso_extended_string(tommorrow) << endl; cout << "tommorrow_start is " << to_iso_extended_string(tommorrow_start) << endl;
//starting at current time iterator adds by one hour time_iterator titr(now,hours(1)); for (; titr < tommorrow_start; ++titr) { cout << to_iso_extended_string(*titr) << endl; } }
-- /*******************/ ×ÔÓÉ£šliberty£©ÎÞ·ÇŸÍÊÇÕâÑùÒ»ÖÖ³Ðŵ£ºÃ¿žöÈËœ«»áµÃµœÒ»ÖÖ±£ÕÏ£¬±£ÕÏÎÒÃÇ¿É ÒÔ Óë ÈšÍþ¡¢¶àÊý¡¢Á÷Ë׌°ÓßÂÛµÄÓ°ÏìÏ࿹ºâ¡£ /*******************/
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Thanks
--
/*******************/
×ÔÓÉ£šliberty£©ÎÞ·ÇŸÍÊÇÕâÑùÒ»ÖÖ³Ðŵ£ºÃ¿žöÈËœ«»áµÃµœÒ»ÖÖ±£ÕÏ£¬±£ÕÏÎÒÃÇ¿ÉÒÔÓë
ÈšÍþ¡¢¶àÊý¡¢Á÷Ë׌°ÓßÂÛµÄÓ°ÏìÏ࿹ºâ¡£
/*******************/
"Black Ice"
boost version 2002-01-02 VC 7.1 Final Beta "error C2668: 'abs' : ambiguous call to overloaded function" when compile following code. The same code can be built successfully in vc6. Any suggestion are appreciated.
#define DATE_TIME_INLINE #define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
#include <iostream> #include <string> using namespace std;
#include
#include using namespace boost::gregorian; using namespace boost::posix_time;
void testDateTime2() { date d(2002, Nov, 1); //an arbitrary date ptime t1(d, hours(5) + nanosec(100));//date + time of day offset ptime t2 = t1 - minutes(4)+seconds(2); ptime now = second_clock::local_time(); //use the clock //Get the date part out of the time date today = now.date(); date tommorrow = today + date_duration(1); ptime tommorrow_start(tommorrow); //midnight
cout << "d is " << to_iso_extended_string(d) << endl; cout << "t1 is " << to_iso_extended_string(t1) << endl; cout << "t2 is " << to_iso_extended_string(t2) << endl; cout << "now is " << to_iso_extended_string(now) << endl; cout << "today is " << to_iso_extended_string(today) << endl; cout << "tommorrow is " << to_iso_extended_string(tommorrow) << endl; cout << "tommorrow_start is " << to_iso_extended_string(tommorrow_start) << endl;
//starting at current time iterator adds by one hour time_iterator titr(now,hours(1)); for (; titr < tommorrow_start; ++titr) { cout << to_iso_extended_string(*titr) << endl; } }
-- /*******************/ ×ÔÓÉ£šliberty£©ÎÞ·ÇŸÍÊÇÕâÑùÒ»ÖÖ³Ðŵ£ºÃ¿žöÈËœ«»áµÃµœÒ»ÖÖ±£ÕÏ£¬±£ÕÏÎÒÃÇ¿ÉÒÔ Óë ÈšÍþ¡¢¶àÊý¡¢Á÷Ë׌°ÓßÂÛµÄÓ°ÏìÏ࿹ºâ¡£ /*******************/
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
participants (4)
-
Black Ice
-
Darin Adler
-
Jeff Holle
-
s_j_turner <s_j_turner@yahoo.co.uk>