Thread: trigraphs

  1. #1
    life is a nightmare
    Join Date
    Apr 2007


    trigraphs i know it's a set of three letters that get treats as they ware one letter
    but how does it help me !!
    i am confusing about that
    in the tutorial he said that there is different character sets the one that programs are written in and the one that programs execute with how could that be ?
    i mean when i write this
    it turns into another character set ? so my question is
    why to use trigraphs?

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Northern Virginia/Washington DC Metropolitan Area
    The reason for their existence is that the basic character set of C is a subset of the ASCII character set (nine of its characters lie outside the smaller ISO 646 invariant character set). This can pose a problem for writing source code if the keyboard being used does not support any of these nine characters. The ANSI C committee invented trigraphs as a way of entering source code using keyboards that supported any version of the ISO 646 character set. Non-ASCII ISO 646 character sets are not much used today, but trigraphs remain in the C standard.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    life is a nightmare
    Join Date
    Apr 2007
    Trigraphs are not commonly encountered outside compiler test suites. Some compilers either have an option to turn recognition of trigraphs off, or disable trigraphs by default and require an option to turn them on. Some can issue warnings when they encounter trigraphs in source files.
    that's why my compiler witch i really hate "dev cpp" gives me errors
    thanks for the link

  4. #4
    Registered User
    Join Date
    Sep 2006
    GCC supports trigraphs but they are not enabled by default. You can use either the -ansi or -trigraphs options to enable them.
    In C mode, support all ISO C90 programs. In C++ mode, remove GNU
    extensions that conflict with ISO C++.

    This turns off certain features of GCC that are incompatible with
    ISO C90 (when compiling C code), or of standard C++ (when compiling
    C++ code), such as the "asm" and "typeof" keywords, and predefined
    macros such as "unix" and "vax" that identify the type of system
    you are using. It also enables the undesirable and rarely used ISO
    trigraph feature. For the C compiler, it disables recognition of
    C++ style // comments as well as the "inline" keyword.
    Support ISO C trigraphs. The -ansi option (and -std options for
    strict ISO C conformance) implies -trigraphs.
    Edit: BTW, you shouldn't care about trigraphs unless you actually have one of these ancient keyboards. But the -ansi option is useful, since it's a good idea to use the options "-W -Wall -ansi -pedantic" to turn on lots of useful warnings.
    Last edited by robatino; 06-21-2007 at 01:03 PM.

Popular pages Recent additions subscribe to a feed