469,591 Members | 1,989 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,591 developers. It's quick & easy.

Porting from Windows to Linux - template class derivative compilationproblems

I have an application that I originally built using Visual Studio .NET 2003
as native C++ [unmanaged code]. This application includes a template class
that was derived from the string class that's part of the C++ STL.
Specifically, it extends the class with some additional methods to support
changes in encoding as well as sprintf-style in-place formatting.

Now, I've been asked to provide a version of the application running on
Linux. I'm using GCC as the C++ compiler, initially with v3.4.6 that's
built into CygWin, and then later I'll use GCC natively on a SUSE Linux
v9/v10 desktop to finish the porting. Initially, I'm just seeking a clean
compile on the same source code & headers in both GCC and Visual C/C++.

This derived class is somewhat messy due to the usage of templates, but
there's no way around them when extending the basic_string template class in
the STL.

Anyway, what I'm interested in are some decent articles that discuss
differences in the two C++ compilers, especially issues related to relaxed
language syntax in Microsoft Visual C/C++ vs. stricter syntax in GCC and how
template classes are handled. The code won't compile as-is, and after
working at it a bit, I'm thinking that there's something I'm failing to
understand regarding how to properly code the derived class that's based on
the basic_string template class.
TIA,

Chuck
--
Chuck Chopp

ChuckChopp (at) rtfmcsi (dot) com http://www.rtfmcsi.com

RTFM Consulting Services Inc. 864 801 2795 voice & voicemail
103 Autumn Hill Road 864 801 2774 fax
Greer, SC 29651

"Racing to save lives"
The Leukemia & Lymphoma Society - Team in Training
http://www.active.com/donate/tntsc/tntscCChopp

Do not send me unsolicited commercial email.
Aug 24 '06 #1
4 3392
Chuck Chopp wrote:
I have an application that I originally built using Visual Studio .NET 2003
as native C++ [unmanaged code]. This application includes a template class
that was derived from the string class that's part of the C++ STL.
Specifically, it extends the class with some additional methods to support
changes in encoding as well as sprintf-style in-place formatting.

Now, I've been asked to provide a version of the application running on
Linux. I'm using GCC as the C++ compiler, initially with v3.4.6 that's
built into CygWin, and then later I'll use GCC natively on a SUSE Linux
v9/v10 desktop to finish the porting. Initially, I'm just seeking a clean
compile on the same source code & headers in both GCC and Visual C/C++.

This derived class is somewhat messy due to the usage of templates, but
there's no way around them when extending the basic_string template class in
the STL.

Anyway, what I'm interested in are some decent articles that discuss
differences in the two C++ compilers, especially issues related to relaxed
language syntax in Microsoft Visual C/C++ vs. stricter syntax in GCC and how
template classes are handled. The code won't compile as-is, and after
working at it a bit, I'm thinking that there's something I'm failing to
understand regarding how to properly code the derived class that's based on
the basic_string template class.
Why not post some code and copy the error messages you're getting so we
can see? Better yet, reduce it to a small test case before posting.
But if I had to hazard a guess, you've mistakenly omitted the word
"typename" (and possibly "template" as well) in a number of key places,
and Visual C++ is letting you get away with it, while gcc is being
strict. If you're unsure which is right, try executing your code on
Comeau's online compiler:

http://www.comeaucomputing.com/tryitout/

Best regards,

Tom

Aug 24 '06 #2
Chuck Chopp wrote:
I have an application that I originally built using Visual Studio .NET
2003
as native C++ [unmanaged code]. This application includes a template
class that was derived from the string class that's part of the C++ STL.
Specifically, it extends the class with some additional methods to support
changes in encoding as well as sprintf-style in-place formatting.
There is already a precedent for this, Jeff Garlands Super_string. It is
available in the Boost "Vault". I do not know if this provides all the
functionality you wan't, but it might be worth a look:
http://www.boost-consulting.com/vault/
Look under "Strings - Text Processing", then pick super_string_v2.zip.
Now, I've been asked to provide a version of the application running on
Linux. I'm using GCC as the C++ compiler, initially with v3.4.6 that's
built into CygWin, and then later I'll use GCC natively on a SUSE Linux
v9/v10 desktop to finish the porting. Initially, I'm just seeking a clean
compile on the same source code & headers in both GCC and Visual C/C++.
Be aware that more recent versions of GCC than 3.4.6 are generally even
stricter in accepting C++ programs.
Anyway, what I'm interested in are some decent articles that discuss
differences in the two C++ compilers, especially issues related to relaxed
language syntax in Microsoft Visual C/C++ vs. stricter syntax in GCC [...]
I can not offer a comparison between GCC and Visual C++, but if you did not
already read it, the "Known Bugs" section of GCC might be of interested to
you:
http://gcc.gnu.org/bugs.html#known
Maybe the following links can help you too. The documents linked are at
least in part meant (if I recall correctly) to help overcome problems
encountered when the Debian distribution of GNU/Linux switched to a newer
version of GCC. Some C++ programs contained in that distribution had
problems with the stricter checking of that newer version, so the documents
might be of help to you too.
http://womble.decadentplace.org.uk/c...plate-faq.html
http://womble.decadentplace.org.uk/c...ax-errors.html
Aug 24 '06 #3
Thomas Tutone wrote:
Why not post some code and copy the error messages you're getting so we
can see? Better yet, reduce it to a small test case before posting.
But if I had to hazard a guess, you've mistakenly omitted the word
"typename" (and possibly "template" as well) in a number of key places,
and Visual C++ is letting you get away with it, while gcc is being
strict. If you're unsure which is right, try executing your code on
Comeau's online compiler:

http://www.comeaucomputing.com/tryitout/
Thanks for the info about the online compiler.

As for getting error messages & code to post, yes, if I can distill it down
to a very simple case that demonstrates the problem then I'll get it posted.
--
Chuck Chopp

ChuckChopp (at) rtfmcsi (dot) com http://www.rtfmcsi.com

RTFM Consulting Services Inc. 864 801 2795 voice & voicemail
103 Autumn Hill Road 864 801 2774 fax
Greer, SC 29651

"Racing to save lives"
The Leukemia & Lymphoma Society - Team in Training
http://www.active.com/donate/tntsc/tntscCChopp

Do not send me unsolicited commercial email.
Aug 25 '06 #4
Volker Lukas wrote:
There is already a precedent for this, Jeff Garlands Super_string. It is
available in the Boost "Vault". I do not know if this provides all the
functionality you wan't, but it might be worth a look:
http://www.boost-consulting.com/vault/
Look under "Strings - Text Processing", then pick super_string_v2.zip.
I'll take a look at it. If it's possible to wrap it up & make it fit in
transparently then I'll give it a try. However, it's still got to work
equally well on Windows, Linux, and, as I just found out this evening, Mac
OS-X, too.
Be aware that more recent versions of GCC than 3.4.6 are generally even
stricter in accepting C++ programs.
Understood. I was fairly certain that Visual C/C++ was being excessively
relaxed & permissive and was allowing something to slip thru and work w/o
the compiler bitching up a storm when building the project.
I can not offer a comparison between GCC and Visual C++, but if you did not
already read it, the "Known Bugs" section of GCC might be of interested to
you:
http://gcc.gnu.org/bugs.html#known
Nothing immediately leapt out at me as seeming like a possible source for
the problem, which leads me to believe it's something in the code that
MSVC++ is accepting but which GCC is unhappy with.
--
Chuck Chopp

ChuckChopp (at) rtfmcsi (dot) com http://www.rtfmcsi.com

RTFM Consulting Services Inc. 864 801 2795 voice & voicemail
103 Autumn Hill Road 864 801 2774 fax
Greer, SC 29651

"Racing to save lives"
The Leukemia & Lymphoma Society - Team in Training
http://www.active.com/donate/tntsc/tntscCChopp

Do not send me unsolicited commercial email.
Aug 25 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Michael Sgier | last post: by
1 post views Thread by Sunanda | last post: by
8 posts views Thread by rays | last post: by
7 posts views Thread by Lior | last post: by
reply views Thread by Michael Palmer | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.