compile Bjarne Stoustrup's Matrix example under MS Visual C++ 6.0

Discussion in 'C++' started by Peter _Grafenberger, Jul 22, 2003.

  1. hi,

    i've some troubles compiling Bjarne Strostrup's Matrix class example

    http://www.research.att.com/~bs/matrix.c

    under ms visual c++ 6.0 (sp4). i get a lot off errors like

    matrix_klasse_by_stroustup.cxx(37) : error C2143: Syntaxfehler :
    Missing ';' before '<'

    for code like

    friend bool operator==<>(const Slice_iter& p, const Slice_iter& q);

    -- 60 errors in total --
    when i compile it on linux (with gcc 3.3) or on sgi everything is fine
    and with intel c++ (win) i get only 3 errors for redefining a variable
    (which seems to be right?!) and after removing this it is also fine.

    do i miss a compiler flag or is there a general problem with ms vc++
    6.0 (and if so is it also present in version 7.0)

    kind regards

    peter

    ------------------------------------------------------------------------
    p.s: compiler flags:

    kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
    advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
    odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
    comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
    odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no
    /pdb:"Release/simple_tests.pdb" /machine:I386
    /out:"Release/simple_tests.exe"
     
    Peter _Grafenberger, Jul 22, 2003
    #1
    1. Advertising

  2. "Peter _Grafenberger" <> wrote...
    > i've some troubles compiling Bjarne Strostrup's Matrix class example
    > [...]
    > do i miss a compiler flag or is there a general problem with ms vc++
    > 6.0 (and if so is it also present in version 7.0)


    This is a PERFECT question to ask in microsoft.public.vc.language.
    Please post any compiler-specific questions to a newsgroup for that
    compiler.

    Victor
     
    Victor Bazarov, Jul 22, 2003
    #2
    1. Advertising

  3. Peter _Grafenberger

    stephan beal Guest

    Ron Natalie wrote:
    > Don't call it matrix.c. Most C++ compilers will treat files that end in
    > .c as the C language.


    Actually, he didn't name it *.c:
    matrix_klasse_by_stroustup.cxx(37) : error C2143: Syntaxfehler :
    Missing ';' before '<'


    --
    ----- stephan beal
    Registered Linux User #71917 http://counter.li.org
    I speak for myself, not my employer. Contents may
    be hot. Slippery when wet. Reading disclaimers makes
    you go blind. Writing them is worse. You have been Warned.
     
    stephan beal, Jul 22, 2003
    #3
  4. Peter _Grafenberger

    Kevin Saff Guest

    "Peter _Grafenberger" <> wrote in message
    news:...
    >
    > friend bool operator==<>(const Slice_iter& p, const Slice_iter& q);
    >
    > -- 60 errors in total --
    > when i compile it on linux (with gcc 3.3) or on sgi everything is fine
    > and with intel c++ (win) i get only 3 errors for redefining a variable
    > (which seems to be right?!) and after removing this it is also fine.
    >
    > do i miss a compiler flag or is there a general problem with ms vc++
    > 6.0 (and if so is it also present in version 7.0)


    MSVC6 is notoriously bad at template code. Off the top of my head, partial
    specialization and template member functions are both not supported, and
    complicated templates tend to increase the likelihood of an internal
    compiler error. I haven't used 7, so I don't know if it works any better.
    I recommend using anything other than 6 if you have any choice in the
    matter.
     
    Kevin Saff, Jul 22, 2003
    #4
  5. In article <>,
    Peter _Grafenberger <> wrote:
    >hi,
    >
    >i've some troubles compiling Bjarne Strostrup's Matrix class example
    >
    >http://www.research.att.com/~bs/matrix.c
    >
    >under ms visual c++ 6.0 (sp4). i get a lot off errors like
    >
    >matrix_klasse_by_stroustup.cxx(37) : error C2143: Syntaxfehler :
    >Missing ';' before '<'
    >
    >for code like
    >
    >friend bool operator==<>(const Slice_iter& p, const Slice_iter& q);


    Remove the "<>"'s on the various operator members, fix the for
    scoping issues, and this compiles and appears to execute just fine
    under VC++6.0 and VC++7.0. (Modulo compiler whine level.)

    Before I get flamed for mentioning compiler specific matters, is
    this really the correct friend declaration? What were the design
    decisions behind not using something like

    template<> friend operator==(const Slice_iter& p, const Slice_iter& q);

    instead? I'm sure Stroustrup is right, but it just looks wrong.
    Some idiot (ok, me) might think that there is a C++ operator called
    "==<>", instead of realizing that operator== is a template function.
     
    Keith A. Lewis, Jul 23, 2003
    #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. lvcargnini

    Matrix composed by two matrix

    lvcargnini, Jul 4, 2006, in forum: VHDL
    Replies:
    3
    Views:
    2,719
    Jonathan Bromley
    Jul 5, 2006
  2. Nagaraj
    Replies:
    1
    Views:
    913
    Lionel B
    Mar 1, 2007
  3. Holgerson

    Matrix*Vector and Vector*Matrix

    Holgerson, Oct 25, 2007, in forum: C++
    Replies:
    3
    Views:
    436
    Holgerson
    Oct 26, 2007
  4. Terry Reedy
    Replies:
    0
    Views:
    587
    Terry Reedy
    Apr 2, 2009
  5. Robert Kern
    Replies:
    0
    Views:
    624
    Robert Kern
    Apr 2, 2009
Loading...

Share This Page