以下程序使用gcc編譯,但不使用g ++,我只生成目標文件。爲什麼這個程序使用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++中,我認爲這是不可能的。 – kernel