c - 具有特定地址的指针声明

标签 c pointers

考虑一下:

(volatile unsigned long *) 0x4000703C

此语句是否意味着我们声明了一个指针指向地址0x4000703C?并且:

#define STEPPER (*((volatile unsigned long *)0x4000703C))

void Step(void){
  STEPPER = 10;
  STEPPER = 9;
  STEPPER = 5;
  STEPPER = 6;
}

STEPPER 是对地址0x4000703C 指针的引用,我们直接写入0x4000703C。是否正确?

最佳答案

Does this statement mean we declare a pointer to the address

不,声明包含一个标识符,在这种情况下是一个变量名。您有一个将整数转换为指针类型的操作,指向 0x4000703C。什么都没有声明。

STEPPER is the deference of the pointer at the address 0x4000703C, and we are writing directly to 0x4000703C. Is it correct?

是的。 0x4000703C 处有什么样的内存当然完全是系统特定的。

关于c - 具有特定地址的指针声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21749467/

相关文章:

C多维数组堆赋值

在 C 中从多个 char 数组字段创建 int 值

c - 如果向 strcat 传递常量,为什么它无法正常工作?

c - 动态分配内存

c - 如何从 void 函数中检索数组并传递给 Main 中的其他函数?

arrays - PowerShell 中有函数指针或函数数组吗?

const int 到 int 无法正常工作

c - Arduino伺服结构 "does not name a type"

c++ - 复制指向对象指针的构造函数

c - 我们如何在 C 中通过指针获取整个字符串?