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

Bizarre compiler warnings

Postby Dzhefri » Mon May 15, 2006 8:53 am

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[i]);
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?
Dzhefri
New poster
 
Posts: 8
Joined: Mon May 15, 2006 8:46 am

Postby mf » Mon May 15, 2006 10:55 am

Try to add '#include <string>' to your program.
mf
Guru
 
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland

Postby Dzhefri » Mon May 15, 2006 7:06 pm

Yeah, that fixed it! (Feeling pretty dumb, though!) Any idea why it would still compile on my machine though?
Dzhefri
New poster
 
Posts: 8
Joined: Mon May 15, 2006 8:46 am

Postby Carlos » Tue May 16, 2006 1:21 am

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.
User avatar
Carlos
System administrator
 
Posts: 1278
Joined: Sat Oct 13, 2001 2:00 am
Location: Valladolid, Spain


Return to Bugs and suggestions

Who is online

Users browsing this forum: No registered users and 1 guest