Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are dollar-signs allowed in identifiers in C++03?

Tags:

c++

identifier

What does the C++ standard say about using dollar signs in identifiers, such as Hello$World? Are they legal?

like image 940
Gili Avatar asked Jun 01 '09 20:06

Gili


People also ask

Can an identifier have a dollar sign?

Dollar signs in identifiersDollar ( $ ) signs are permitted in identifiers.

Is Dollar valid identifier in C?

AFAIK, it is not allowed in C .

Is Dollar Sign valid variable name?

dollar sign ('$') is an illegal character. class is a Python keyword with its special syntax. It can't be used a variable name. A name cannot contain a space Otherwise put, the space character (' ') is illegal in a name, just as '$' is.

What is the use of dollar in C?

In GNU C, you may normally use dollar signs in identifier names. This is because many traditional C implementations allow such identifiers. However, dollar signs in identifiers are not supported on a few target machines, typically because the target assembler does not allow them.


1 Answers

A c++ identifier can be composed of any of the following: _ (underscore), the digits 0-9, the letters a-z (both upper and lower case) and cannot start with a number.

There are a number of exceptions as C99 allows extensions to the standard (e.g. visual studio).

like image 108
Kevin Loney Avatar answered Oct 12 '22 18:10

Kevin Loney