The meaning of @ symbol in C language includes: pointing to variable address, format string, specified attribute, preprocessor directive, GCC extension (such as printing file name, line number and function name).
Meaning of @ in C language
@ symbol in C language has multiple meanings depending on its location of use.
1. Point to the address of a variable
When @ is used as a unary operator, it returns the address of its operand variable. For example:
<code class="c">int x = 5; int *ptr = &x; // ptr 指向 x 的地址</code>
2. Format string
Use the @ symbol to specify a format string for formatted output. For example:
<code class="c">printf("%@d", x); // 以十进制格式打印 x</code>
3. Attributes
In C99 and later, the @ symbol can be used to specify attributes of a function or variable. For example:
<code class="c">@noreturn int my_function(); // 指示 my_function() 函数将不返回</code>
4. Preprocessor directives
In the C preprocessor, the @ symbol is used to specify preprocessor directives. For example:
<code class="c">#define PI 3.14159265 // 定义一个常量</code>
5. GCC extensions
The GCC compiler provides several @ extensions:
These extensions are only available in the GCC compiler.
The above is the detailed content of What does c language @ mean?. For more information, please follow other related articles on the PHP Chinese website!