Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #76624

Re: dollar sign in variable name

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: dollar sign in variable name
Date 2015-11-20 03:32 -0800
Organization None to speak of
Message-ID <lna8q8ewjh.fsf@kst-u.example.com> (permalink)
References <de259813-bcaf-4334-9fa8-a2cfff5d2251@googlegroups.com> <n2lpf3$aiu$1@dont-email.me>

Show all headers | View raw


Richard Heathfield <rjh@cpax.org.uk> writes:
> On 20/11/15 00:18, Jay Braun wrote:
>> I was just playing around in gcc, and named a variable game$time, and
>> a function set_game$time, and the compiler accepted it.  The small
>> program linked and ran fine as well.  This required no special
>> options.
>>
>> Would I be playing with fire if I used dollar signs in identifiers?
>
> Not if you're happy for your code only to be compilable with gcc, no.
>
> Such things are called "extensions". Any compiler writer can offer 
> extensions as long as they don't interfere with what is often called 
> "legal" C code. Dollar signs don't interfere (because they're 
> "illegal"), so no "legal" C program can include them, and so allowing 
> them cannot break any "legal" C program, so it's fine. But don't expect 
> it to work when compiled by implementations other than gcc.

Strictly speaking, it's not an extension in the sense used in N1570 4p6.
If it were, a diagnostic would still be required when the compiler is
invoked in conforming mode.

6.4.2.1, which defines the syntax of identifiers, permits "other
implementation-defined characters".  That wasn't the case in C90.
(Which is why "gcc -std=c90 -pedantic" warns about it, but
"gcc -std=c99 -pedantic" doesn't.)



-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

dollar sign in variable name Jay Braun <lyngwyst@gmail.com> - 2015-11-19 16:18 -0800
  Re: dollar sign in variable name BartC <bc@freeuk.com> - 2015-11-20 00:27 +0000
    Re: dollar sign in variable name Jay Braun <lyngwyst@gmail.com> - 2015-11-19 16:29 -0800
      Re: dollar sign in variable name Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2015-11-19 20:05 -0700
  Re: dollar sign in variable name Richard Heathfield <rjh@cpax.org.uk> - 2015-11-20 00:30 +0000
    Re: dollar sign in variable name Jay Braun <lyngwyst@gmail.com> - 2015-11-19 16:37 -0800
      Re: dollar sign in variable name Ian Collins <ian-news@hotmail.com> - 2015-11-20 13:42 +1300
        Re: dollar sign in variable name BartC <bc@freeuk.com> - 2015-11-20 00:47 +0000
          Re: dollar sign in variable name Philipp Klaus Krause <pkk@spth.de> - 2015-11-21 17:24 +0100
            Re: dollar sign in variable name Philip Lantz <prl@canterey.us> - 2015-11-22 15:37 -0800
      Re: dollar sign in variable name Robert Wessel <robertwessel2@yahoo.com> - 2015-11-19 23:22 -0600
        Re: dollar sign in variable name glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-20 06:51 +0000
    Re: dollar sign in variable name Keith Thompson <kst-u@mib.org> - 2015-11-20 03:32 -0800
    Re: dollar sign in variable name Ken Brody <kenbrody@spamcop.net> - 2015-11-23 13:27 -0500
  Re: dollar sign in variable name Barry Schwarz <schwarzb@dqel.com> - 2015-11-19 16:41 -0800
  Re: dollar sign in variable name glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-20 00:53 +0000
  Re: dollar sign in variable name Geoff <geoff@invalid.invalid> - 2015-11-19 21:40 -0800
  Re: dollar sign in variable name David Brown <david.brown@hesbynett.no> - 2015-11-20 11:04 +0100
  Re: dollar sign in variable name Jay Braun <lyngwyst@gmail.com> - 2015-11-20 06:35 -0800

csiph-web