dollar sign is legal in gcc

This is a discussion on dollar sign is legal in gcc within the Linux Programming forums, part of the Platform Specific Boards category; hi, consider this: #include <iostream.h> int main() { int $one; cout << $one; return 0; } i've tried this code ...

  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
    B26354 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, 10: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, 01:24 PM
  3. My own itoa()
    By maxorator in forum C++ Programming
    Replies: 18
    Last Post: 10-15-2006, 12:49 PM
  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, 04:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21