1
我試圖在我正在執行的C++項目中爲我的實體實現UUID。我使用的是Visual Studio Professional 2012.當包含特定的boost文件頭時,標準非boost文件中的錯誤
我能夠包含並且無任何錯誤,但我也希望uuid_io.hpp能夠將UUID轉換爲字符串或者只是將其輸出到stdout,但是隻要我包含它,我會得到很多錯誤,看起來與任何boost文件都沒有關係。
我使用msvc11的32位Windows二進制從here.
我有一個共同的包括文件看起來像這樣:
//Common.h
#ifndef COMMON_H
#define COMMON_H
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <map>
#include <curses.h>
#include <panel.h>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include "Map.h"
#include "Tile.h"
#include "Grid.h"
#include "Entity.h"
#endif
(curses.h和panel.h是從該pdcurses項目,從here.下載)
這是我得到的輸出:
1>------ Build started: Project: Curses, Configuration: Debug Win32 ------
1> Map.cpp
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\algorithm(35): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocbuf(273): warning C4002: too many actual parameters for macro 'erase'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocbuf(283): warning C4002: too many actual parameters for macro 'erase'
1>e:\lib\boost_1_55_0\boost\io\ios_state.hpp(121): warning C4002: too many actual parameters for macro 'clear'
1>e:\lib\boost_1_55_0\boost\io\ios_state.hpp(126): warning C4002: too many actual parameters for macro 'clear'
1>e:\lib\boost_1_55_0\boost\io\ios_state.hpp(382): warning C4002: too many actual parameters for macro 'clear'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(557): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(603): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(610): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(617): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(642): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(1331): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(1494): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(1521): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\functional(239): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(494): error C2059: syntax error : '('
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(464) : while compiling class template member function 'std::string std::money_get<_Elem,_InIt>::_Getmfld(_InIt &,_InIt &,bool,std::ios_base &,_Elem *) const'
1> with
1> [
1> _Elem=char,
1> _InIt=std::istreambuf_iterator<char,std::char_traits<char>>
1> ]
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(415) : see reference to function template instantiation 'std::string std::money_get<_Elem,_InIt>::_Getmfld(_InIt &,_InIt &,bool,std::ios_base &,_Elem *) const' being compiled
1> with
1> [
1> _Elem=char,
1> _InIt=std::istreambuf_iterator<char,std::char_traits<char>>
1> ]
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(950) : see reference to class template instantiation 'std::money_get<_Elem,_InIt>' being compiled
1> with
1> [
1> _Elem=char,
1> _InIt=std::istreambuf_iterator<char,std::char_traits<char>>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(495): error C2039: '_Off' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(495): error C2039: '_Sign' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(497): error C2059: syntax error : '('
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(499): error C2039: '_Source' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(499): error C2039: '_Symbol' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(499): error C2668: 'std::basic_string<_Elem,_Traits,_Alloc>::begin' : ambiguous call to overloaded function
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xstring(1578): could be 'std::_String_const_iterator<_Mystr> std::basic_string<_Elem,_Traits,_Alloc>::begin(void) throw() const'
1> with
1> [
1> _Mystr=std::_String_val<std::_Simple_types<char>>,
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xstring(1573): or 'std::_String_iterator<_Mystr> std::basic_string<_Elem,_Traits,_Alloc>::begin(void) throw()'
1> with
1> [
1> _Mystr=std::_String_val<std::_Simple_types<char>>,
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> while trying to match the argument list '(void)'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(636): error C2059: syntax error : '('
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(637): error C2039: '_Neg' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(638): error C2039: '_Val' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> Entity.cpp
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\algorithm(35): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocbuf(273): warning C4002: too many actual parameters for macro 'erase'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocbuf(283): warning C4002: too many actual parameters for macro 'erase'
1>e:\lib\boost_1_55_0\boost\io\ios_state.hpp(121): warning C4002: too many actual parameters for macro 'clear'
1>e:\lib\boost_1_55_0\boost\io\ios_state.hpp(126): warning C4002: too many actual parameters for macro 'clear'
1>e:\lib\boost_1_55_0\boost\io\ios_state.hpp(382): warning C4002: too many actual parameters for macro 'clear'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(557): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(603): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(610): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(617): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(642): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(1331): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(1494): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(1521): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\functional(239): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(494): error C2059: syntax error : '('
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(464) : while compiling class template member function 'std::string std::money_get<_Elem,_InIt>::_Getmfld(_InIt &,_InIt &,bool,std::ios_base &,_Elem *) const'
1> with
1> [
1> _Elem=char,
1> _InIt=std::istreambuf_iterator<char,std::char_traits<char>>
1> ]
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(415) : see reference to function template instantiation 'std::string std::money_get<_Elem,_InIt>::_Getmfld(_InIt &,_InIt &,bool,std::ios_base &,_Elem *) const' being compiled
1> with
1> [
1> _Elem=char,
1> _InIt=std::istreambuf_iterator<char,std::char_traits<char>>
1> ]
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(950) : see reference to class template instantiation 'std::money_get<_Elem,_InIt>' being compiled
1> with
1> [
1> _Elem=char,
1> _InIt=std::istreambuf_iterator<char,std::char_traits<char>>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(495): error C2039: '_Off' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(495): error C2039: '_Sign' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(497): error C2059: syntax error : '('
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(499): error C2039: '_Source' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(499): error C2039: '_Symbol' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(499): error C2668: 'std::basic_string<_Elem,_Traits,_Alloc>::begin' : ambiguous call to overloaded function
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xstring(1578): could be 'std::_String_const_iterator<_Mystr> std::basic_string<_Elem,_Traits,_Alloc>::begin(void) throw() const'
1> with
1> [
1> _Mystr=std::_String_val<std::_Simple_types<char>>,
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xstring(1573): or 'std::_String_iterator<_Mystr> std::basic_string<_Elem,_Traits,_Alloc>::begin(void) throw()'
1> with
1> [
1> _Mystr=std::_String_val<std::_Simple_types<char>>,
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> while trying to match the argument list '(void)'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(636): error C2059: syntax error : '('
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(637): error C2039: '_Neg' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(638): error C2039: '_Val' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> Application.cpp
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\algorithm(35): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocbuf(273): warning C4002: too many actual parameters for macro 'erase'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocbuf(283): warning C4002: too many actual parameters for macro 'erase'
1>e:\lib\boost_1_55_0\boost\io\ios_state.hpp(121): warning C4002: too many actual parameters for macro 'clear'
1>e:\lib\boost_1_55_0\boost\io\ios_state.hpp(126): warning C4002: too many actual parameters for macro 'clear'
1>e:\lib\boost_1_55_0\boost\io\ios_state.hpp(382): warning C4002: too many actual parameters for macro 'clear'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(557): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(603): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(610): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(617): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(642): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(1331): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(1494): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\memory(1521): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\functional(239): warning C4003: not enough actual parameters for macro 'move'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(494): error C2059: syntax error : '('
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(464) : while compiling class template member function 'std::string std::money_get<_Elem,_InIt>::_Getmfld(_InIt &,_InIt &,bool,std::ios_base &,_Elem *) const'
1> with
1> [
1> _Elem=char,
1> _InIt=std::istreambuf_iterator<char,std::char_traits<char>>
1> ]
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(415) : see reference to function template instantiation 'std::string std::money_get<_Elem,_InIt>::_Getmfld(_InIt &,_InIt &,bool,std::ios_base &,_Elem *) const' being compiled
1> with
1> [
1> _Elem=char,
1> _InIt=std::istreambuf_iterator<char,std::char_traits<char>>
1> ]
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(950) : see reference to class template instantiation 'std::money_get<_Elem,_InIt>' being compiled
1> with
1> [
1> _Elem=char,
1> _InIt=std::istreambuf_iterator<char,std::char_traits<char>>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(495): error C2039: '_Off' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(495): error C2039: '_Sign' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(497): error C2059: syntax error : '('
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(499): error C2039: '_Source' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(499): error C2039: '_Symbol' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(499): error C2668: 'std::basic_string<_Elem,_Traits,_Alloc>::begin' : ambiguous call to overloaded function
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xstring(1578): could be 'std::_String_const_iterator<_Mystr> std::basic_string<_Elem,_Traits,_Alloc>::begin(void) throw() const'
1> with
1> [
1> _Mystr=std::_String_val<std::_Simple_types<char>>,
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> d:\program (x86)\microsoft visual studio 11.0\vc\include\xstring(1573): or 'std::_String_iterator<_Mystr> std::basic_string<_Elem,_Traits,_Alloc>::begin(void) throw()'
1> with
1> [
1> _Mystr=std::_String_val<std::_Simple_types<char>>,
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> while trying to match the argument list '(void)'
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(636): error C2059: syntax error : '('
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(637): error C2039: '_Neg' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>d:\program (x86)\microsoft visual studio 11.0\vc\include\xlocmon(638): error C2039: '_Val' : is not a member of 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我會建議刪除包含文件,直到找到導致問題的文件,然後查看那個文件。但是,如果我必須猜測,我會說某人正在定義一個名爲「clear」的宏,並且這會導致問題。 –
更多證據:boost/io/ios_state.hpp第121行包含對'{s.clear(a); }',其中's'是傳入例程的參數。錯誤消息「對於宏'清除'太多的實際參數」看起來更具說服力。 –
罪魁禍首確實是由這種方法決定的。 curses.h和panel.h頭文件放置在boost頭文件之前引起問題,將它們移動到Common.h文件中的最後,以使程序能夠無錯地編譯,謝謝! :) – Armandur