Porting from Windows to Linux - template class derivative compilationproblems

Discussion in 'C++' started by Chuck Chopp, Aug 24, 2006.

  1. Chuck Chopp

    Chuck Chopp Guest

    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.
     
    Chuck Chopp, Aug 24, 2006
    #1
    1. Advertising

  2. Re: Porting from Windows to Linux - template class derivative compilation problems

    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
     
    Thomas Tutone, Aug 24, 2006
    #2
    1. Advertising

  3. Chuck Chopp

    Volker Lukas Guest

    Re: Porting from Windows to Linux - template class derivative compilation problems

    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 /template-faq.html
    http://womble.decadentplace.org.uk/c /syntax-errors.html
     
    Volker Lukas, Aug 24, 2006
    #3
  4. Chuck Chopp

    Chuck Chopp Guest

    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.
     
    Chuck Chopp, Aug 25, 2006
    #4
  5. Chuck Chopp

    Chuck Chopp Guest

    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.
     
    Chuck Chopp, Aug 25, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Terry Mulvany

    System.Web.UI.Page derivative...

    Terry Mulvany, Mar 2, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    671
    Terry Mulvany
    Mar 3, 2004
  2. Terry Mulvany
    Replies:
    2
    Views:
    2,954
    Terry Mulvany
    Mar 3, 2004
  3. xhunga
    Replies:
    3
    Views:
    279
    xhunga
    Mar 10, 2007
  4. xhunga
    Replies:
    0
    Views:
    326
    xhunga
    Mar 10, 2007
  5. xhunga
    Replies:
    0
    Views:
    316
    xhunga
    Mar 16, 2007
Loading...

Share This Page