Thread: dollar sign is legal in gcc

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    3

    dollar sign is legal in gcc

    hi,

    consider this:

    #include <iostream.h>

    int main()
    {
    int $one;

    cout << $one;
    return 0;
    }

    i've tried this code on bcc 5.5 and it does not compile, but on gcc 2.95 (on linux) it compiles perfectly. why?

  2. #2
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    GG is correct. The '$' character may not be part of an identifier under ANSI C. You can force gcc to adhere strictly to ANSI C by using the -ansi switch in your compiles. What you lose with the -ansi switch are the keywords asm, inline, and typeof (as well as some macros). The gcc man page has all the details.
    Jason Deckard

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Compiles on gcc 3.3 but not on gcc 4.0.3
    By cunnus88 in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2007, 12:24 PM
  3. My own itoa()
    By maxorator in forum C++ Programming
    Replies: 18
    Last Post: 10-15-2006, 11:49 AM
  4. Can't get output to display dollar sign
    By carolsue2 in forum C++ Programming
    Replies: 5
    Last Post: 02-28-2006, 12:10 PM
  5. gcc
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 10-22-2003, 03:46 PM