The attribute in GUN C

Source: Internet
Author: User

A major feature of GNU C is the __attribute__ mechanism. __attribute__ can set function properties (functionsattribute), variable properties (Variable attribute), and

The type attribute (Attribute).

__attribute__ writing features are:There are two underscores before and after the __attribute__, and the next one is immediately followed by a pair of original brackets, the corresponding __attribute__ parameters in parentheses.

__ATTRIBUTE__ syntax Format:__attribute__ ((attribute-list))

Its position constraint is placed before the end of the declaration ";".

Keyword __attribute__ You can alsoset property settings for a struct (struct) or a common body (Union). There are roughly six parameter values that can be set, namely:aligned, packed,

Transparent_union, unused, deprecated and may_alias.

When using the __attribute__ parameter, you can also add "__" (two underscores) before and after the parameter, for example, using __aligned__ instead of aligned, so You can use it in the corresponding header file without worrying about whether there is a macro definition with the same name in the header file.

Aligned (alignment)

This property sets a gill (in bytes) of the specified size, for example:

struct S {

Short b[3];

} __attribute__ ((aligned (8)));

typedef int INT32_T __ATTRIBUTE__ ((aligned (8)));

Http://www.cnblogs.com/astwish/p/3460618.html

The attribute in GUN C

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.