473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Barton-Nackman and compilation under Solaris

Dear group readers,
I use the Barton-Nackman trick in my code, and I can compile it
correctly with Visual Studio 7.0 but have problem when trying to cmpile
Sun/Solaris Compiler C/C++. The problem comes from the following line
of code, the error is "multiple decoration for MYBASECLASS". I hope
that you have had a solution for the problem otherwise I will have to
recoding to remove the template.

class MYDERIVEDCLASS:public MYBASECLASS<MYDERIVEDCLASS> {
friend class MYBASECLASS;
}

Where I have define MYBASECLASS as:

template<typename ADerivedSolver> class MYBASECLASS{}
Hope to hear from you soon.
Regards,
Xuan Son

Jan 17 '06 #1
4 1550
ng***********@gmail.com wrote:
I use the Barton-Nackman trick in my code, and I can compile it
correctly with Visual Studio 7.0 but have problem when trying to cmpile
Sun/Solaris Compiler C/C++.
First of all, have you read the FAQ? I think that section 5 is the most
relevant. If you have a problem with code, post the code. If you have
a problem with a particular compiler, post to that compiler newsgroup
before posting here.
The problem comes from the following line
of code, the error is "multiple decoration for MYBASECLASS".
You mean "multiple _declaration_", for sure?
I hope
that you have had a solution for the problem otherwise I will have to
recoding to remove the template.

class MYDERIVEDCLASS:public MYBASECLASS<MYDERIVEDCLASS> {
friend class MYBASECLASS;
'MYBASECLASS' here is not a class. MYBASECLASS<MYDERIVEDCLASS> is. You
need to change this to

friend class MYBASECLASS<MYDERIVEDCLASS>;
}

Where I have define MYBASECLASS as:

template<typename ADerivedSolver> class MYBASECLASS{}


Instead of using English, use C++, it is easier to understand. Like this:
------------------------------ code

template<typename A> class MYBASECLASS {};
class MYDERIVEDCLASS:public MYBASECLASS<MYDERIVEDCLASS> {
friend class MYBASECLASS;
};

------------------------------ end code
Now, I can then take it as is and pass it through my compiler...

Anyway, you have your solution, I hope.

V
Jan 17 '06 #2
TB
ng***********@gmail.com sade:
Dear group readers,
I use the Barton-Nackman trick in my code, and I can compile it
correctly with Visual Studio 7.0 but have problem when trying to cmpile
Sun/Solaris Compiler C/C++. The problem comes from the following line
of code, the error is "multiple decoration for MYBASECLASS". I hope
that you have had a solution for the problem otherwise I will have to
recoding to remove the template.

class MYDERIVEDCLASS:public MYBASECLASS<MYDERIVEDCLASS> {
friend class MYBASECLASS;
}

Where I have define MYBASECLASS as:

template<typename ADerivedSolver> class MYBASECLASS{}


I guess you didn't mean

#define MYBASECLASS template<typename ADerivedSolver> class MYBASECLASS{}

as I read it and thought "what the hell?" :)

--
TB @ SWEDEN
Jan 17 '06 #3
TB wrote:
ng***********@gmail.com sade:
Dear group readers,
I use the Barton-Nackman trick in my code, and I can compile it
correctly with Visual Studio 7.0 but have problem when trying to cmpile
Sun/Solaris Compiler C/C++. The problem comes from the following line
of code, the error is "multiple decoration for MYBASECLASS". I hope
that you have had a solution for the problem otherwise I will have to
recoding to remove the template.

class MYDERIVEDCLASS:public MYBASECLASS<MYDERIVEDCLASS> {
friend class MYBASECLASS;
}

Where I have define MYBASECLASS as:

template<typename ADerivedSolver> class MYBASECLASS{}

I guess you didn't mean

#define MYBASECLASS template<typename ADerivedSolver> class MYBASECLASS{}

as I read it and thought "what the hell?" :)


When people say "define a class" they rarely mean using the preprocessor
"define" directive. A definition of a class (or a class template) differs
from a declaration by the existence of the _body_. So, when the OP said
"I have define[d] BLAH as", the presence of the curly braces indicates
that it's a _definition_.

I can say, "I defined my 'foo' function as

void foo(int a) {
cout << a;
}
"

which is supposed to bring your attention to the _body_. Compare it to
what you'd be looking at/for if I said, "I declared my 'foo' function as

void foo(int);

". The body (and the side effects) are irrelevant.

HTH

V
Jan 17 '06 #4
TB
Victor Bazarov sade:
TB wrote:
ng***********@gmail.com sade:
Dear group readers,
I use the Barton-Nackman trick in my code, and I can compile it
correctly with Visual Studio 7.0 but have problem when trying to cmpile
Sun/Solaris Compiler C/C++. The problem comes from the following line
of code, the error is "multiple decoration for MYBASECLASS". I hope
that you have had a solution for the problem otherwise I will have to
recoding to remove the template.

class MYDERIVEDCLASS:public MYBASECLASS<MYDERIVEDCLASS> {
friend class MYBASECLASS;
}

Where I have define MYBASECLASS as:

template<typename ADerivedSolver> class MYBASECLASS{}

I guess you didn't mean

#define MYBASECLASS template<typename ADerivedSolver> class MYBASECLASS{}

as I read it and thought "what the hell?" :)


When people say "define a class" they rarely mean using the preprocessor
"define" directive. A definition of a class (or a class template) differs

<snip>

Actually he said "Where I have define MYBASECLASS as:" and when reading
the all-capital-letter name my mind accidently switched into
#define-context, so I became perplexed.

--
TB @ SWEDEN
Jan 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chang Zhu | last post by:
I use forms to enter data. Once data is entered in the first form, I save it and then open the second form. Parts of the data for the second form (such as id, name) will come from the first form....
9
by: Barton | last post by:
Hello, I just made to move to ASP. I have been developing in PHP the past two years. I must say that I'm a little disappointed in the quality of the beginners tutorials. They don't go further...
4
by: ethan220 | last post by:
Is it possible to read Outlook mails in PHP?? I would like to create a php program that reads mails from a particular person which are downloaded in MS Outlook. Ethan
2
by: pjSoni | last post by:
Hi All, I've created .png image for chart it's size is big so I want scrollbar below it so that user can scroll from right to left and at same time image should be scroll. I think it can be done...
6
by: JaxDawg | last post by:
OK... Crazy (possibly dumb) question here... I have a site running apache, mysql, php in a Win2K environment. Primary development is that env also. I also am setting up a linux box (old laptop),...
76
bartonc
by: bartonc | last post by:
If you like me and think the ms cmd.exe really bites, check out consol2 here.
15
by: mdmytryk | last post by:
Hey, im new to computer programming as well as python, so please be gentle. Im working on a program that will calculate grades. When a value other than A,B,C,D, or F is entered, i want the program...
3
by: DDCane | last post by:
i need to make a dictonary that works like so: when u type: vote(dict,person): it should vote for that person in question by modifying the dictionary and if the person does not exist it creates...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.