以下程序可以使用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
如何解决这个问题?