Bizarre compiler warnings

The forum to report every bug you find or tell us what you'd like to find in UVa OJ

Moderator: Board moderators

Locked
Dzhefri
New poster
Posts: 8
Joined: Mon May 15, 2006 8:46 am

Bizarre compiler warnings

Post by Dzhefri »

I've never had any weird problems getting my submitted code to be compiled, but all the sudden I can't figure out what's going on.

My C++ program begins:

1 #include <iterator>
2 #include <ctype.h>
3 #include <iostream>
4 #include <vector>
5 #include <algorithm>
6
7 using namespace std;
8
9 string to_caps(const string s) {
10 string out;
11 for (int i = 0; i < s.size(); ++i) {
12 out += toupper(s);
13 }
14 return out;
15 }

and so on. (I didn't include line numbers in my submitted code; they're added here for your convenience.) I'm then told my code won't compile, and returned the following error messages:

Here are the compiler error messages:

04576192_24.c:9: syntax error before `('
04576192_24.c:11: `s' was not declared in this scope
04576192_24.c:11: parse error before `;'
04576192_24.c:20: parse error before `{'
04576192_24.c:24: syntax error before `='
04576192_24.c:26: `s1' was not declared in this scope
04576192_24.c:26: `s1' was not declared in this scope

and so on. This compiles just fine on my computer here, using "powerpc-apple-darwin8-g++-4.0.0 (GCC) 4.0.0 20041026 (Apple Computer, Inc. build 4061)". I've tried submitting both by uploading the file on the submit-o-matic and also by cutting and pasting the code there -- it doesn't make any difference. Can anybody figure this one out?
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

Try to add '#include <string>' to your program.
Dzhefri
New poster
Posts: 8
Joined: Mon May 15, 2006 8:46 am

Post by Dzhefri »

Yeah, that fixed it! (Feeling pretty dumb, though!) Any idea why it would still compile on my machine though?
Carlos
System administrator
Posts: 1286
Joined: Sat Oct 13, 2001 2:00 am
Location: Valladolid, Spain
Contact:

Post by Carlos »

maybe your compiler added string header file automatically...or it was included by another header file.
DON'T PM ME --> For any doubt, suggestion or error reporting, please use the "Contact us" form in the web.
Locked

Return to “Bugs and suggestions”