cnamespacesnaming-conventionsnon-ascii-charactersstandards-compliance

Non-ASCII characters in C


I was looking at google go's runtime source code (at https://go.googlecode.com/hg/src/pkg/runtime/ ), and it seems they use a special character for their function names, · . (Look for example at https://go.googlecode.com/hg/src/pkg/runtime/cgocall.c ). Is this accepted across major compilers? It's not ANSI C, is it? Or is it just some macro magic?

Thank you!


Solution

  • C90 doesn't allow additional character in identifier (over those in the basic characters set), C99 do (both with the universal character syntax -- \uXXXX and \UXXXXXXXX -- and an implementation defined set of other characters).

    6.4.2.1/1 in C99:

    identifier:
        identifier-nondigit
        identifier identifier-nondigit
        identifier digit
    identifier-nondigit:
        nondigit
        universal-character-name
        other implementation-defined characters
    nondigit: one of
        _ a b c d e f g h i j k l m
        n o p q r s t u v w x y z
        A B C D E F G H I J K L M
        N O P Q R S T U V W X Y Z
    digit: one of
        0 1 2 3 4 5 6 7 8 9
    

    I don't know how well it is supported by C implementations, I know that Plan9 C compiler could handle other characters before it was standardized.