The first character in an identifier must be a letter or the _ (underscore) character; however, beginning identifiers with an underscore is considered poor programming style.
The compiler distinguishes between uppercase and lowercase letters in identifiers. For example, PROFIT and profit represent different identifiers. If you specify a lowercase a as part of an identifier name, you cannot substitute an uppercase A in its place; you must use the lowercase letter.
The universal character names for letters and digits outside of the basic source character set are allowed at the C99 language level.
The
dollar sign can appear in identifier names when compiled using the -qdollar compiler
option or at one of the extended language levels that encompasses
this option.
Identifiers with two initial underscores or an initial underscore followed by an uppercase letter are reserved globally for use by the compiler.
Identifiers that begin with a single underscore are reserved as identifiers with file scope in both the ordinary and tag namespaces.
Although the names of system calls and library functions are not reserved words if you do not include the appropriate headers, avoid using them as identifiers. Duplication of a predefined name can lead to confusion for the maintainers of your code and can cause errors at link time or run time. If you include a library in a program, be aware of the function names in that library to avoid name duplications. You should always include the appropriate headers when using standard library functions.
static const char __func__[] = "function-name";
where function-name is
the name of the lexically-enclosing function. For debugging purposes, you can explicitly use the __func__ identifier to return the name of the function in which it appears. For example:
#include <stdio.h>
void myfunc(void) {
printf("%s\n",__func__);
printf("size of __func__ = %d\n", sizeof(__func__));
}
int main() {
myfunc();
}
The output of the program is:
myfunc
size of __func__ = 7
When the assert macro is used inside a function definition, the macro adds the name of the enclosing function on the standard error stream.
The compiler binds each non-static external variable and function name in the source code to a name that it generates in the object file and any assembly code that is emitted. For compatibility with GCC, the compiler implements an extension to standard C that allows you to specify the name to be used in the object file and assembly code, by applying an assembly label to the declaration of a global variable or function prototype. You can also define names that do not start with an underscore even on systems where an underscore is normally prepended to the name of a function or variable.
Assembly label syntax >>-declarator--+-asm-----+--(--"--string_literal--"--)----------> +-__asm__-+ '-__asm---' >--+-------------+--------------------------------------------->< '-initializer-'
The string_literal is a valid assembly name that is to be bound to the given object or function. For a label applied to a function declaration, the name must specify an existing function that is defined in any compilation unit; if no definition is available, a link-time error will occur. For a label applied to a variable declaration, no other definition is required.
void func3() __asm__("foo3");
int i __asm("abc");
char c asm("abcs") = 'a';