The role of the typeof keyword.

Source: Internet
Author: User

The role of the typeof keyword.
Http://blog.chinaunix.net/uid-28458801-id-4200573.html

 

I. typeof:

Preface:
The typeof keyword is a new extension in C language, which is widely used in Linux kernel. (In fact, this is similar to the auto keyword of C ++ and the decltype keyword that can be inferred)

 

Ii. Example:

1. Define y as the data type pointed to by x:

Typeof (* x) y;

2. Define y to point x to an array of data types:

Typeof (* x) y [4];

3. Define y as a character pointer array:
Typeof (char *) [4] y;
This is equivalent to the following definition:
Char * y [4];

4, typeof (int *) p1, p2;/* Declares two int pointers p1, p2 */
Int * p1, * p2;

5, typeof (int) * p3, p4;/* Declares int pointer p3 and int p4 */
Int * p3, p4;

6, typeof (int [10]) a1, a2;/* Declares two arrays of integers */
Int a1 [10], a2 [10];

 

 

3. , Limitations

Type name in typeof ConstructionNoContains Storage Class specifiers, suchExternOrStatic. However, type delimiters are allowed, suchConstOrVolatile. For example, the following code is invalid because it declares extern In the typeof construction:
Typeof (extern int);



Iv. File Reference

1, http://blog.csdn.net/wslong/article/details/7728811

Http://gcc.gnu.org/onlinedocs/gcc/Typeof.html#Typeof 2

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.