鱼C论坛

 找回密码
 立即注册
查看: 3812|回复: 1

#define宏定义

[复制链接]
发表于 2013-8-3 13:40:28 | 显示全部楼层 |阅读模式
5鱼币
本帖最后由 dt3tc 于 2013-8-3 13:42 编辑

我知道#define是宏定义指令,但这个代码中的“#define Py_ASDL_H”语句不像啊(宏名后无字符串),请问这句是什么意思
  1. #ifndef Py_ASDL_H
  2. #define Py_ASDL_H

  3. typedef PyObject * identifier;
  4. typedef PyObject * string;
  5. typedef PyObject * object;

  6. /* It would be nice if the code generated by asdl_c.py was completely
  7.    independent of Python, but it is a goal the requires too much work
  8.    at this stage.  So, for example, I'll represent identifiers as
  9.    interned Python strings.
  10. */

  11. /* XXX A sequence should be typed so that its use can be typechecked. */

  12. typedef struct {
  13.     int size;
  14.     void *elements[1];
  15. } asdl_seq;

  16. typedef struct {
  17.     int size;
  18.     int elements[1];
  19. } asdl_int_seq;

  20. asdl_seq *asdl_seq_new(int size, PyArena *arena);
  21. asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena);

  22. #define asdl_seq_GET(S, I) (S)->elements[(I)]
  23. #define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
  24. #ifdef Py_DEBUG
  25. #define asdl_seq_SET(S, I, V) { \
  26.         int _asdl_i = (I); \
  27.         assert((S) && _asdl_i < (S)->size); \
  28.         (S)->elements[_asdl_i] = (V); \
  29. }
  30. #else
  31. #define asdl_seq_SET(S, I, V) (S)->elements[I] = (V)
  32. #endif

  33. #endif /* !Py_ASDL_H */
复制代码
from python 3.1.3\include\asdl.h

最佳答案

查看完整内容

#define Py_ASDL_H 就是把Py_ASDL_H 定义为什么都没有,这里兵不是为了把Py_ASDL_H定义成什么特殊的东西,主要是为了#ifndef检测是否定义过Py_ASDL_H
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-8-3 13:40:29 | 显示全部楼层
#define Py_ASDL_H
就是把Py_ASDL_H
定义为什么都没有,这里兵不是为了把Py_ASDL_H定义成什么特殊的东西,主要是为了#ifndef检测是否定义过Py_ASDL_H
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-16 06:21

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表