* vector
@ 2002-08-22 4:40 Dan Mergens
2002-08-22 5:02 ` vector Laurent Pinchart
2002-08-22 8:27 ` vector Norman Vine
0 siblings, 2 replies; 4+ messages in thread
From: Dan Mergens @ 2002-08-22 4:40 UTC (permalink / raw)
To: cygwin
I'm baffled why this simple program produces the following errors.
Strangly enough, if I remove the push_back call, it compiles without
complaint.
I'm running the latest version of cygwin. I'm sure I'm missing
something...
Thanks,
Dan
-------------- test.C ------------------
#include <vector>
void main() {
vector<int> array;
array.push_back(10);
}
----------------------------------------
$ gcc test.C
/cygdrive/c/DOCUME~1/dan/LOCALS~1/Temp/ccSFn9EF.o(.__malloc_alloc_template<0>::t
ext$_S_oom_malloc(unsigned int)+0x1a):main.C: undefined reference to
`endl(ostre
am &)'
/cygdrive/c/DOCUME~1/dan/LOCALS~1/Temp/ccSFn9EF.o(.__malloc_alloc_template<0>::t
ext$_S_oom_malloc(unsigned int)+0x27):main.C: undefined reference to
`cerr'
/cygdrive/c/DOCUME~1/dan/LOCALS~1/Temp/ccSFn9EF.o(.__malloc_alloc_template<0>::t
ext$_S_oom_malloc(unsigned int)+0x2c):main.C: undefined reference to
`ostream::o
perator<<(char const *)'
collect2: ld returned 1 exit status
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: vector
2002-08-22 4:40 vector Dan Mergens
@ 2002-08-22 5:02 ` Laurent Pinchart
2002-08-22 7:54 ` vector Gerrit P. Haase
2002-08-22 8:27 ` vector Norman Vine
1 sibling, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2002-08-22 5:02 UTC (permalink / raw)
To: cygwin; +Cc: Dan Mergens
> I'm baffled why this simple program produces the following errors.
> Strangly enough, if I remove the push_back call, it compiles without
> complaint.
[...]
> $ gcc test.C
[...]
It's a C++ program. You have to use g++. Naming your file test.cpp instead of
test.C would be a good idea too.
Laurent Pinchart
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: vector
2002-08-22 5:02 ` vector Laurent Pinchart
@ 2002-08-22 7:54 ` Gerrit P. Haase
0 siblings, 0 replies; 4+ messages in thread
From: Gerrit P. Haase @ 2002-08-22 7:54 UTC (permalink / raw)
To: cygwin
Hallo Laurent,
Am Donnerstag, 22. August 2002 um 10:15 schriebst du:
>> I'm baffled why this simple program produces the following errors.
>> Strangly enough, if I remove the push_back call, it compiles without
>> complaint.
> [...]
>> $ gcc test.C
> [...]
> It's a C++ program. You have to use g++. Naming your file test.cpp instead of
> test.C would be a good idea too.
.C (upper case is an official filename suffix for C++ too!
Using g++ on this example gives errors too:
$ g++ -c vector.C
vector.C:2: `main' must return `int'
vector.C: In function `int main(...)':
vector.C:3: `vector' undeclared (first use this function)
vector.C:3: (Each undeclared identifier is reported only once for each function
it appears in.)
vector.C:3: parse error before `>' token
vector.C:4: `array' undeclared (first use this function)
Gerrit
--
perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: vector
2002-08-22 4:40 vector Dan Mergens
2002-08-22 5:02 ` vector Laurent Pinchart
@ 2002-08-22 8:27 ` Norman Vine
1 sibling, 0 replies; 4+ messages in thread
From: Norman Vine @ 2002-08-22 8:27 UTC (permalink / raw)
To: 'Dan Mergens', cygwin
Dan Mergens writes:
>
>I'm baffled why this simple program produces the following errors.
>Strangly enough, if I remove the push_back call, it compiles without
>complaint.
>
>I'm running the latest version of cygwin. I'm sure I'm missing
>something...
>
>Thanks,
>Dan
>
>-------------- test.C ------------------
>#include <vector>
>void main() {
>vector<int> array;
>array.push_back(10);
>}
>----------------------------------------
This is really OT for this list but since there have been several
similar posts recently
< please use a general C++ programming list >
try
// compile with g++ < or c++ >
// c++ test.C
// if compiling with gcc libstdc++ must be linked explicitly
// gcc test.C -lstdc++
#include <vector>
int main(void) {
std::vector<int> array;
array.push_back(10);
return 0;
}
note that main() MUST be declared to return an int
and that vector<> MUST be qualified
Norman
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-08-22 12:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-22 4:40 vector Dan Mergens
2002-08-22 5:02 ` vector Laurent Pinchart
2002-08-22 7:54 ` vector Gerrit P. Haase
2002-08-22 8:27 ` vector Norman Vine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).