Reputation: 580
I recently installed xcode command line tools on my Mac. Its OS is version 10.9.5. To test out the g++ compiler I created a simple "hello world" c++ program, called it program.cpp and put it on my desktop:
#include <iostream>
using namespace std;
int main()
{
cout<<“Hello World”;
return 0;
}
Then I intended to create a compiled version of program.cpp, opened terminal, changed my directory to the desktop and typed the following command:
g++ -o program program.cpp
I received the following compilation errors:
program.cpp:7:11: error: non-ASCII characters are not allowed outside of
literals and identifiers
cout<<“Hello World”;
^
program.cpp:7:14: error: use of undeclared identifier 'Hello'
cout<<“Hello World”;
^
program.cpp:7:25: error: non-ASCII characters are not allowed outside of
literals and identifiers
cout<<“Hello World”;
^
3 errors generated.
Is this a problem with the command line tools or something else? Any help would be appreciated.
Upvotes: 1
Views: 565
Reputation: 764
There might be an "U.S. International - PC" input method set on your mac (assuming you are on mac) and that has accented characters which result in '“' being inserted when you expected '"'.
Upvotes: 0
Reputation: 122401
You aren't using double quote characters:
“Hello World”
is not the same as:
"Hello World"
I guess this is due to a copy-and-paste from PDF or something, as programs like Word like to change "" to “”.
Also if you are using the Xcode Command Line tools, you are actually using clang and not g++.
Upvotes: 3