Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Peter _Grafenberger
Guest
 
Posts: n/a
#1: Jul 19 '05
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"

Victor Bazarov
Guest
 
Posts: n/a
#2: Jul 19 '05

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


"Peter _Grafenberger" <peter.grafenberger@vatech-hydro.at> wrote...[color=blue]
> 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)[/color]

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


stephan beal
Guest
 
Posts: n/a
#3: Jul 19 '05

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


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

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.

Kevin Saff
Guest
 
Posts: n/a
#4: Jul 19 '05

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



"Peter _Grafenberger" <peter.grafenberger@vatech-hydro.at> wrote in message
news:48dc857d.0307220718.56847ed4@posting.google.c om...[color=blue]
>
> 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)[/color]

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.


Keith A. Lewis
Guest
 
Posts: n/a
#5: Jul 19 '05

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


In article <48dc857d.0307220718.56847ed4@posting.google.com >,
Peter _Grafenberger <peter.grafenberger@vatech-hydro.at> wrote:[color=blue]
>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);[/color]

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.
Closed Thread