在 AIX 上编译 netcat

发布于 2024-09-02 17:11:04 字数 385 浏览 3 评论 0原文

我尝试在 AIX 上编译 netcat.c 一段时间了(使用命令 make aix),但编译器给了我一些奇怪的反馈,例如:

“netcat.c”,第 117.12 行:1506 -275 (S) 遇到意外的文本“int”。

当检查文件 netcat.c 的第 117 行时,我会找到该行(下面代码中的第二行):

#ifdef HAVE_BIND
extern int h_errno;
/* stolen almost wholesale from bsd herror.c */

即使我将 int 更改为 char 进行相同的测试,保存文件并重新运行命令我得到同样的错误,

我在读取错误代码时遗漏了一些东西吗?

I have been trying to compile netcat.c on AIX for some time (using the command make aix), but the compiler gives me some weird feedback such as :

"netcat.c", line 117.12: 1506-275 (S) Unexpected text 'int' encountered.

when checked the file netcat.c at line 117, I would find the line (second line in code below):

#ifdef HAVE_BIND
extern int h_errno;
/* stolen almost wholesale from bsd herror.c */

even if I changed the int into char for the same of testing, save the file and re-run the command I get the same error

am I missing something in reading the error code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

黯然#的苍凉 2024-09-09 17:11:04

如果您使用的是 xlc(尤其是较旧的),它通常是由语句后的声明引起的,例如:

i = i + 1;
int x;

您可能需要给我们更多的上下文,例如错误之前的 10 行左右线。

如果您使用较旧的 xlc,我的建议是在该机器上运行 gcc。 IBM 现在制作了一些优秀的编译器,但早期的编译器并没有那么热门(在我看来)。

If you're using xlc (especially older ones), it's normally caused by declarations after statements, something like:

i = i + 1;
int x;

You probably need to give us a little more context, such as 10 or so lines before the error line.

My advice would be to get gcc running on that box if you are using an older xlc. IBM makes some fine compilers now but the earlier ones weren't so crash hot (in my opinion).

只为一人 2024-09-09 17:11:04

当看似无害的代码产生奇怪的错误时,请尝试通过 C 预处理器阶段运行代码,然后查看它。有时宏会做一些非常有趣的事情。

另请注意,前一行的问题(缺少分号等)可能会在后一行产生错误消息。

When innocent-looking code produces bizarre errors, try running the code through the C preprocessor stage, and looking at it then. Sometimes macros do very funny things.

Also note that a problem on an earlier line (missing semicolon, etc.) might produce an error message on a later line.

一指流沙 2024-09-09 17:11:04

这篇文章可能已经有点过时了,但以防万一其他人遇到同样的问题......

这里(AIX 7.1)h_errno 被定义为 netdb.h 中的宏。

/usr/include/netdb.h:#define h_errno   (*(int *)h_errno_which())

因此netcat.c第117行中的声明不起作用。

我刚刚将行更改为

#ifndef h_errno
extern int h_errno;
#endif

,编译工作顺利。

The post maybe already a little outdated, but just in case someone else comes along with the same problem ...

Here (AIX 7.1) h_errno is defined as macro in netdb.h.

/usr/include/netdb.h:#define h_errno   (*(int *)h_errno_which())

Therefore the declaration in netcat.c line 117 does not work.

I just changed the line into

#ifndef h_errno
extern int h_errno;
#endif

and the compilation worked smoothly.

饭团 2024-09-09 17:11:04

@A.Rashad,我将 HAVE_BIND #ifdef 块从第 117 行移至第 30 行,该行位于 #include "generic.h" 声明下方。这允许 xlc 对其进行编译。 (S) 语法错误消息消失了,虽然有一些 (W) 警告消息,但我最后得到了一个 nc 二进制文件!

哈,

凯文

@A.Rashad, I moved the HAVE_BIND #ifdef block from line 117 to line 30 which is just under the #include "generic.h" declaration. This permitted the xlc to compile it. The (S)yntax error messages are gone and while there are some (W)arning messages, I do get an nc binary at the end!

hth,

Kevin

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文