- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
当我使用 typedef 中的名称时,出现了很多错误。但是在我将名称修改为原始名称后,它就可以工作了。我想知道它们之间有什么不同。
void SwapPoint(Point *pos1, Point *pos2);
//errors
void SwapPoint(struct point *pos1, struct point *pos2);
//it works
void SwapPoint(Point *pos1, Point *pos2);
typedef struct point
{
int xpos;
int ypos;
}Point;
void SwapPoint(Point *pos1, Point *pos2)
{
Point temp;
temp = *pos1;
*pos1 = *pos2;
*pos2 = temp;
}
there's no ')' in front of '*'
there's no '{' in front of '*'
there's no ';' in front of '*'
最佳答案
两个函数声明:
void SwapPoint(Point *pos1, Point *pos2);
//errors
void SwapPoint(struct point *pos1, struct point *pos2);
//it works
即使您为第二个函数声明写了“it works”,在 C 中也是无效的。请注意 visual-studio 编译器存在许多错误,并且其自身的语言扩展不满足 C 标准。
第一个声明无效,因为尚未定义名称 Point
。
第二个函数声明无效,因为 struct point
类型在函数声明之外是不可见的,并且不表示在函数声明下方定义的类型。那就是参数类型和这个结构体声明的不一样
typedef struct point
{
int xpos;
int ypos;
}Point;
来自 C 标准(6.2.1 标识符的范围)
- ... If the declarator or type specifier that declares the identifier appears within the list of parameter declarations in a function prototype (not part of a function definition), the identifier has function prototype scope, which terminates at the end of the function declarator.
因此将 typedef 放在两个函数声明之前。
关于c - 声明另一个函数时使用函数名和昵称(由 typedef 制成)有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58606746/
有没有办法通过 ejabberd 服务器获取 MUC Room 的所有昵称? 我正在尝试: 但我只获得没有昵称的 jid: 最佳答案 在 6.5 Qu
有人知道获取用户 App Store 昵称的方法吗?我知道 CloudKit 方法 fetchUserRecordIDWithCompletionHandler,但这会返回用户的名字和姓氏,而不是用户
这个接口只能获得一些非敏感信息,例如用户昵称,用户头像,经过用户授权允许获取的情况下即可获得用户信息,至于openid这些,需要调取wx.login来获取。 index.wxml
在 python xmpp 模块中,我可以按如下方式检索任何联系人的昵称: self.connection.auth(userJid.getNode(), self.password) self.ro
我想在我的 XMPP 聊天消息中添加自定义属性(昵称),如下例 hello 我知道,XMPP 不推荐但这是我的要求,因为这个属性(nick)已经在我正在使用的应用程序的 iOS 版本中实现上。 最佳答
我是一名优秀的程序员,十分优秀!