473,320 Members | 1,952 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,320 software developers and data experts.

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 3665
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: WittyGuy | last post by:
Hi all, Though I know the concepts of both abstract class & virtual function (like derived class pointer pointing to base class...then calling the function with the pointer...), what is the real...
2
by: Michael Sgier | last post by:
Hello i'm trying to port a windows program to linux with Kdevelop 1.question: unsigned char *LoadBitmapFile(char *filename, BITMAPINFOHEADER *bitmapInfoHeader); ...
1
by: Sunanda | last post by:
Hi, I am a newbie to .Net. I have an application in running in linux, a set of .c and .h files. I also have a makefile in linux to create the executable. I want to port this to windows...
3
by: IR | last post by:
Hi, I've been trying to do the following (which doesn't compile) : template<class T, class F = Example<T struct Example { F foo(); };
5
by: StephQ | last post by:
This is from a thread that I posted on another forum some days ago. I didn't get any response, so I'm proposing it in this ng in hope of better luck :) The standard explanation is that pointer...
8
by: rays | last post by:
Hi, I am trying to port a C++ program which is supposed to be standards compliant. It works fine on Linux with GCC (4.x). But as I try to compile it on Windows, all hell breaks loose. I have been...
7
by: Lior | last post by:
Hi, I have small code, that compiles on Visual C++ into a shared library (DLL). I need to compile it under linux, but the code includes some data types I'm not familiar with, such as DWORD,...
6
by: Lawrence Spector | last post by:
I ran into a problem using g++. Visual Studio 2005 never complained about this, but with g++ I ran into this error. I can't figure out if I've done something wrong or if this is a compiler bug. ...
0
by: Michael Palmer | last post by:
On Sep 16, 12:30 pm, binaryjesus <coolman.gu...@gmail.comwrote: I haven't tried it myself, but I came across a blog post the other day that describes a way of building windows installers for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.