What is meaning of the '_attribute_((aligned(4)));' in the first line?

后端 未结 3 1012
不思量自难忘°
不思量自难忘° 2021-01-25 05:03
char buf[BUF_LEN]_attribute_((aligned(4)));
ssize_t len, i = 0;
/* read BUF_LEN bytes\' worth of events */
len = read (fd, buf, BUF_LEN);
/* loop over every read event u         


        
3条回答
  •  有刺的猬
    2021-01-25 05:09

    char buf[BUF_LEN]_attribute_((aligned(4)));
    

    It specifies a minimum alignment for the variable buf, measured in bytes.
    It causes the compiler to allocate the variable buf on a 4-byte boundary.

    This should be a good read.

提交回复
热议问题