getaddrinfo 中的参数不能使用常量替换?

zhqyzhqychn 2009-04-30 04:56:50
如果服务那个参数用端口号比如“60000”,就可以,但是如果#define PORT 60000,在以“PORT”做为参数调用就说服务不支持,怎么回事
...全文
42 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
morris88 2009-04-30
  • 打赏
  • 举报
回复
确实看漏了,你的代码呢?
zhqyzhqychn 2009-04-30
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 morris88 的回复:]
C/C++ code#define PORT "60000"



定义成字符串常量不行吗?


C/C++ code int getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints,
struct addrinfo **res);
[/Quote]
define PORT 60000 然后以"PORT"调用
和define PORT "60000" 然后以PORT调用不是一个意思吗
  • 打赏
  • 举报
回复
把你的调用贴出来。
#define PORT 60000
server.sin_port=htons(PORT);
这样才可以啊
morris88 2009-04-30
  • 打赏
  • 举报
回复
#define PORT "60000"


定义成字符串常量不行吗?

       int getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints,
struct addrinfo **res);

23,125

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧