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

  • Thread starter Peter _Grafenberger
  • Start date
P

Peter _Grafenberger

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"
 
V

Victor Bazarov

Peter _Grafenberger said:
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
 
S

stephan beal

Ron said:
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.
 
K

Kevin Saff

Peter _Grafenberger said:
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.
 
K

Keith A. Lewis

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top