views:

323

answers:

2

I'm trying to compile a basic "hello world" file with the Open Watcom C++ compiler for Windows.

Here's the error I get:

wpp386 hello.cpp
Open Watcom C++32 Optimizing Compiler Version 1.8
Portions Copyright (c) 1989-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
hello.cpp(7): Error! E064: col(19) invalid character constant                   
hello.cpp: 9 lines, included 7673, no warnings, 1 error

And here's the file:

#include <IOSTREAM>
#include <STRING>
using namespace std;

int main()
{
string mystring = 'Hello world!';
cout <<mystring <<endl;
return 0;
}
+4  A: 

Use double quotes:

string mystring = "Hello, World!";
Michael Krelin - hacker
+2  A: 

Also, use lower case for the names of the #included headers, upper case may or may not work. And Watcom C++ is pretty antique, you will probably be better off switching to a modern C++ implementation like MinGW.

anon
Can you give me some choices of more modern compilers? I can't seem to find any myself.
Hussain
See the link to MinGW in my answer.
anon
I was also surprised at first, but then (1) this error would come first and (2) windows filesystem is case insensitive. On the other hand, with "<>" compiler has the right interpret the files as strings according to its liking, so it should be lowercase, of course. In short, +1 ;-)
Michael Krelin - hacker
This is what I get after making the includes lower case:hello.cpp(8): Error! E157: col(6) left expression must be integralhello.cpp(8): Note! N717: col(6) left operand type is 'std::ostream watcall (lvalue)'hello.cpp(8): Note! N718: col(6) right operand type is 'std::basic_string<char,std::char_traits<char>,std::allocator<char>> (lvalue)'hello.cpp: 9 lines, included 7673, no warnings, 1 error
Hussain
Edit your answer to match the code you are actually compiling. Use copy and paste to do this - DO NOT re-type the code.
anon
+1 for your comment, but that would give stranger an impression that I (and possibly you) have given wrong answer(s) ;-)
Michael Krelin - hacker
I meant of course "edit your question"!
anon
I want to add a note here that while OpenWatcom's compiler is probably inferior to GCC's compiler when it comes to optimization and support, it offers a full development package with IDE, editors (source editor, resource editor, image editor, etc), documentation manuals, up-to-date windows header files, profiler, debugger, etc in all supported platforms. Also it is more "Windows friendly" than MinGW is, due to its UNIX roots (of course the opposite also is true: OpenWatcom isn't very UNIX friendly).
Bad Sector