在AIX 7上编译C代码时出错

时间:2012-08-17 18:43:04

标签: c makefile aix xlc

所以,我被要求在AIX7(64位)盒子上编译一些遗留的C代码。

并且,我刚刚更改了makefile以编辑使用的编译器(从gcc到xlc_r),以及标志,从(-DAIX3到-DAIX7)。

但是,多亏了这个tomfoolery,我收到一个抱怨的错误

    xlc_r -c -q64 -O -DAIX -DAIX7  log.c
  "log.c", line 128.7: 1506-343 (S) Redeclaration of log_write differs from previous declaration on line 140 of "lib.h".
  "log.c", line 128.7: 1506-378 (I) Prototype for function log_write cannot contain "..." when mixed with a nonprototype declaration.
  "log.c", line 165.7: 1506-343 (S) Redeclaration of log_errno differs from previous declaration on line 141 of "lib.h".
 "log.c", line 165.7: 1506-378 (I) Prototype for function log_errno cannot contain "..." when mixed with a nonprototype declaration.
 make: 1254-004 The error code from the last command is 1.

方法问题似乎是

  extern  void    log_write _PROTO(( int, char *, ... ));
  extern  void    log_errno _PROTO(( int, char *, ... ));

我想知道...是什么,它是否为打开的参数列表做了什么?我如何让它在AIX7上运行?

1 个答案:

答案 0 :(得分:2)

函数声明或定义中的省略号(...)表示该函数接受可变数量(零个或多个)参数。

在需要使用符合ANSI和ANSI的前编译器编译代码的日子里,处理C语言两种语言之间的函数声明差异的常用方法是有条件地定义一个宏可以通过更改宏定义来允许ANSI样式声明或K& R样式声明。我怀疑您的示例中使用的_PROTO()宏被定义为具有K& R样式声明而不是原型的ANSI样式声明,修复此问题可能会解决这些编译问题