LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-17-2009, 09:38 AM   #1
aayudh
LQ Newbie
 
Registered: Nov 2008
Posts: 10

Rep: Reputation: 0
porting code to gcc ..template code problems


i am having some problem porting some template code from windows compiler to gcc

this is the function
Code:
template <class _T> inline impl::DeclaratorClass &BindBasicString(const std::string &_name)
{
return Class<_T>(_name)
.Constructor()
.Constructor<const _T&>()       //line 65
.Method("clear", &_T::clear)
.Method("empty", &_T::empty)
.Method("size", &_T::size)
.Constructor<const _T::value_type*>()
.Constructor<const _T::value_type*, _T::size_type>()
.Constructor<const _T&, _T::size_type>()
.Constructor<const _T&, _T::size_type, _T::size_type>()
.Constructor<_T::size_type, _T::value_type>()
.Method("c_str", &_T::c_str)
.Method("push_back", &_T::push_back)
.Operator(Str, &_T::c_str)
.Operator(const_self + const_self)
.Operator(const_self == const_self)
.Operator(const_self == other<const _T::value_type*>())
.Operator(other<const _T::value_type*>() == const_self)
.Operator(impl::BinaryOperatorBaseHolder<ConCat, true, true, const _T>())
.Operator(impl::BinaryOperatorBaseHolder<ConCat, true, true, const _T::value_type*>())
.Operator(impl::BinaryOperatorBaseHolder<ConCat, true, false, const _T::value_type*>())
.Enum("npos", _T::npos);
}

.....


template<class _Class>
struct CustomClass : GenericClass
{
	typedef CustomClass<_Class> Me;

.....
	template<class _P1> inline Me &Constructor(const GenericMethodPolicy &_p = GenericMethodPolicy(0)) {
		return InsertConstructor(new ConstructorClass1<_Class, _P1>(_p)), *this; };
};
The Constructor method below is what is called when .Constructor is called. Now you can download mluabind source code if you want to have a deeper look.

now the errors I get in gcc are as such

/usr/local/mluabind-0.05/impl/../impl/stl_basic_string.h: In function 'mluabind::impl:eclaratorClass& mluabind::BindBasicString(const std::string&)':
/usr/local/mluabind-0.05/impl/../impl/stl_basic_string.h:65: error: expected primary-expression before 'const'
/usr/local/mluabind-0.05/impl/../impl/stl_basic_string.h:65: error: expected ';' before 'const'
/usr/local/mluabind-0.05/impl/../impl/stl_basic_string.h:65: error: expected unqualified-id before '>' token
/usr/local/mluabind-0.05/impl/../impl/stl_basic_string.h:65: error: expected initializer before '>' to

I am assuming gcc template programming is different. Can some understand and help me out with this !!!!

Last edited by aayudh; 01-17-2009 at 09:43 AM.
 
Old 01-17-2009, 03:40 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
You definitely need to change all _T::type to typename _T::type, and you might try changing line 65 to use const typename _T&. Realistically, that probably won't work because most templates aren't designed to allow & in the type. Also, I have no idea how you can keep track of such a long chain of function calls, or why you would have it that way. Are you sure that the second Constructor is actually a template? I'm afraid to ask what the underlying class structure looks like to be able to have such a call, but if you can reduce it so that we can replicate the error on our own machines, please post it.
ta0kira

edit:
At second glance, it seems you keep returning *this and you initialize the same object through a series of member function calls, though the numerous calls to Constructor are ambiguous. Is this a reasonable interpretation?

Last edited by ta0kira; 01-17-2009 at 03:48 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compilation problem in c++ template code :( lali.p Programming 2 10-13-2008 06:44 PM
Porting Code lucky6969b Programming 5 12-14-2005 10:11 PM
Problems when porting code from C++ under visual studio 6 to linux. Stor_G Programming 3 08-26-2004 07:19 AM
Porting C++ code from XP to Linux Bondfire Programming 7 08-12-2004 03:42 PM
Porting c++ code to linux Moons Programming 3 06-03-2004 01:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration