This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Why does GCC allow '$' character in variable and function names?
- From: Ian Lance Taylor <iant at google dot com>
- To: Sajish V <emailsaju at yahoo dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 17 Oct 2006 21:24:56 -0700
- Subject: Re: Why does GCC allow '$' character in variable and function names?
- References: <20061018041155.22546.qmail@web57714.mail.re3.yahoo.com>
Sajish V <emailsaju@yahoo.com> writes:
> I think that C does not allow special characters ( '~' '!' '@' '#' '$' '%' '^' '&' '*' ) in variable and function names. My knowledge is purely based on the books that I have been reading to learn C.
>
> To verify this when I tried to compile a C program using GCC with '$' in variable names and function names I found that GCC does not complain. No errors or warnings.
>
> I used the basic command with no option to compile.
>
> bash$ gcc <filename>
>
> Can someone please let me know why GCC allows '$' character in variable and function names?
The C99 standard permits identifiers to contain implementation defined
characters. See section 6.4.2.1. The standard does this to permit
implementations to support identifiers written in languages which
require characters which do not appear in English, such as 'Ã' or 'Ã'.
gcc permits '$' as an implementation defined character. It does this
mainly for historical reasons.
Ian