【发布时间】:2014-01-10 08:54:09
【问题描述】:
以下程序使用 gcc 而不是 g++ 编译,我只生成目标文件。
这是 prog.c:
#include "prog.h"
static struct clnt_ops tcp_nb_ops = {4};
这是 prog.h:
#ifndef _PROG_
#define _PROG_
#include <rpc/rpc.h>
#endif
当我这样做时:
gcc -c prog.c
生成目标代码,但是,
g++ -c prog.c
给出错误:
variable ‘clnt_ops tcp_nb_ops’ has initializer but incomplete type
如何解决这个问题?
【问题讨论】:
-
结构的定义在哪里???在 C 中我们可以定义这样的结构吗?在 c++ 中我认为这是不可能的。