static member initilization

Mohsen Pahlevanzadeh mohsen@pahlevanzadeh.org
Tue Jul 10 14:32:00 GMT 2012


Also i read who has my problem that his code compiled in other machine
that compiled without error, ref:
http://www.groupsrv.com/computers/about686099.html
On Tue, 2012-07-10 at 17:44 +0430, Mohsen Pahlevanzadeh wrote:
> Sound like a bug, 
> I get the following errors for initialization  line:
> //////////////////////////////////////////////////////////
> main.cpp:10:243: error: conflicting declaration ‘const
> std::vector<std::pair<int, std::basic_string<char> > >
> EventHandlerAbstract<test, int, int, int, int, int>::eventList’
> In file included from main.cpp:3:0:
> Common/eventhandlerabstract.h:114:51: error: ‘EventHandlerAbstract<test,
> int, int, int, int, int>::eventList’ has a previous declaration as
> ‘std::vector<std::pair<int, std::basic_string<char> > >*
> EventHandlerAbstract<test, int, int, int, int, int>::eventList’
> main.cpp:10:243: error: template arguments to
> ‘EventHandlerAbstract<test, int, int, int, int, int>::eventList’ do not
> match original template ‘EventHandlerAbstract<Class, ReturnType,
> Parameter1, Parameter2, Parameter3, Parameter4>::eventList’
> ///////////////////////////////////////////////////////////
> and my initialization line is :
> ////////////////////////////////////////////////////////////////
> template < class Class, typename ReturnType,typename Parameter1  ,
> typename Parameter2 , typename Parameter3 , typename Parameter4 >
> std::vector < std::pair<int, string> >  const EventHandlerAbstract<
> test,int,int,int,int,int >::eventList =
> &EventHandlerAbstract<test,int,int,int,int,int>::eventStaticMemberVectorInit();
> ///////////////////////////////////////////////////////////////////
> I read the following page and now, i think a bug:
> http://preciseinfo.org/Convert/Articles_CPP/Template_Experts/C
> ++-VC-ATL-STL-Template-Experts-06400276.html
> --mohsen
> On Tue, 2012-07-10 at 05:23 -0700, Ian Lance Taylor wrote:
> > On Tue, Jul 10, 2012 at 5:07 AM, Mohsen Pahlevanzadeh
> > <mohsen@pahlevanzadeh.org> wrote:
> > >
> > > but when i initialize my vector such as following line:
> > > ////////////////////////////
> > > template <  >  std::pair<int, string> EventHandlerAbstract<
> > > test,int,int,int,int,int >::eventList =
> > > &EventHandlerAbstract<test,int,int,int,int,int>::eventStaticMemberVectorInit();
> > > ///////////////////////////////////////////////////////////
> > > i get the following errors:
> > > ////////////////////////////////////////////////////////
> > > error: ‘EventHandlerAbstract<test, int, int, int, int, int>::eventList’
> > > has a previous declaration as ‘std::vector<std::pair<int,
> > > std::basic_string<char> > >* EventHandlerAbstract<test, int, int, int,
> > > int, int>::eventList’
> > > main.cpp:9:178: error: ‘EventHandlerAbstract<test, int, int, int, int,
> > > int>::eventList’ cannot be initialized by a non-constant expression when
> > > being declared
> > > ////////////////////////////////////////////////////////
> > 
> > 1) This does not look like a question about how to use GCC.  It looks
> > like a question about how to use C++.
> > 
> > 2) Please try hard to send a complete self-contained example, rather
> > than a collection of little bits of code.  Often the attempt to create
> > an example will answer the question for you.
> > 
> > 3) The declaration of eventList within the class uses
> > std::vector<std::pair<>>, the declaration in the file uses just
> > std::pair, without std::vector.  That is probably the root cause of
> > your problem.
> > 
> > Ian
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 316 bytes
Desc: This is a digitally signed message part
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20120710/59afc6b9/attachment-0001.sig>


More information about the Gcc-help mailing list