473,597 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Porting from Windows to Linux - template class derivative compilationprob lems

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 3685
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
4200
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 implementation usage of these concepts? Where these concepts will be used. Please provide some illustration (real-time), so that it can be easily comprehended. Thanks, wittyGuy
2
2374
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); /home/michael/Desktop/div.OpenGL/linshootme/src/texture.h:51: error: type specifier omitted for parameter `BITMAPINFOHEADER' /home/michael/Desktop/div.OpenGL/linshootme/src/texture.h:51: error: syntax error before `*' token
1
1606
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 (.Net environment).
3
2470
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
2260
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 to functions are hard to inline for the compiler, and so you won't be able to avoid function call overhead. This is an important aspect when you are calling a function very frequently for evaluation reason: think of the problem of performing...
8
2288
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 struggling with several free (as beer) compilers on windows, but none of them does the job. I am not sure how much of the blame goes to our code and how much to the compilers. By the way the platform is Windows XP and all the softwares mentioned...
7
15636
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, HANDLE, __int64, ULONG etc. What are those words?
6
5315
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. Here's a very simple example which should illustrate what I'm doing. #include <iostream> template <class T> class TestBase {
0
1778
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 pyGTK applications at http://unpythonic.blogspot.com/2007/07/pygtk-py2exe-and-inno-setup-for-single.html
0
7969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7886
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8272
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
6688
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5431
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3886
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3927
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2404
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1238
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.