在C语言中,你如何声明结构的成员动荡? [英] In C, how do you declare the members of a structure as volatile?

查看:117
本文介绍了在C语言中,你如何声明结构的成员动荡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何声明一个结构作为挥发性的特定成员?

How do you declare a particular member of a struct as volatile?

推荐答案

完全一样的非 - 结构字段:

Exactly the same as non-struct fields:

#include <stdio.h>
int main (int c, char *v[]) {
    struct _a {
        int a1;
        volatile int a2;
        int a3;
    } a;
    a.a1 = 1;
    a.a2 = 2;
    a.a3 = 3;
    return 0;
}

您可以标记整个结构通过使用挥发性结构_a {...}挥发性,但上述方法是对各个字段。

You can mark the entire struct as volatile by using "volatile struct _a {...}" but the method above is for individual fields.

这篇关于在C语言中,你如何声明结构的成员动荡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆