views:

271

answers:

2

Is '@' used in C++? In this yacc file it is listed as a token. And i am sure i cant use @ as part of a variable name. Is @ used in C++? and how might i use it?

+6  A: 

No, it isn’t used in C++. It doesn’t appear anywhere in the standard. In particular, it does not appear in the set of legal C++ characters [lex.charset].

Konrad Rudolph
Some compilers use `@` though for identifier names after name mangling. See http://en.wikipedia.org/wiki/Name_mangling#How_different_compilers_mangle_the_same_functions for example.
Joey
@Johannes: true but this is strictly irrelevant for the C++ syntax and hence for a lexer spec. In the `yacc` file, the presence of the `@` symbol is a mistake. Furthermore, the symbol isn’t used anywhere else in the `yacc` file.
Konrad Rudolph
A source character doesn't have to be in the _basic_ source character set (so '@' isn't necessarily not allowed), but it must be handled as if it appeared as a \uXXXX universal character escape. So non-basic source characters can't appear in any identifiers or language tokens, but they could appear in character and string literals.
Charles Bailey
A: 

As the above answers mentioned, '@' is not part standard C++; however, it does appear in Objective-C, and hence in Objective-C++, and hence, in real-world code, such as WebKit.

James Turner