读书人

C++关于extern quot;Cquot; {}的有关问题

发布时间: 2012-04-05 12:42:40 作者: rapoo

C++关于extern "C" {}的问题,急!!!
//头文件common.h中
#ifndef ADAPTER_COMMON_H
#define ADAPTER_COMMON_H

#include "platform.h"
#include "debug.h"

#ifdef __cplusplus

extern "C"
{
#endif

/* be carrefull to change those defines : used as array index in the code */
#define TUNE_TIME_LOCKED 0
#define TUNE_TIME_DATA 1
......
......
......
#endif
......
......
......
#endif
#define CHANNEL_MONITORING_REFRESH_REQUESTED 0x20

extern int channel_frequency_band(uint32_t freq_kHz);

......
......
......

struct dibChannel {
uint32_t RF_kHz;
uint32_t bandwidth_kHz;


uint8_t type;

union std {

#ifdef CONFIG_STANDARD_DVBT
struct dibDVBTChannel {
int8_t spectrum_inversion;

int8_t nfft;
int8_t guard;
int8_t constellation;

int8_t hrch;
int8_t alpha;
int8_t code_rate_hp;
int8_t code_rate_lp;
int8_t select_hp;

int8_t intlv_native;
} dvbt;
#endif

#ifdef CONFIG_STANDARD_ISDBT
struct dibISDBTChannel {
int8_t sb_mode; /* 0 = 13seg, 1 = 1 or 3seg */
int8_t partial_reception; /* sb_mode=0 -> 0=no, 1=yes, sb_mode=1 -> 0=1seg, 1=3seg */

int8_t spectrum_inversion; /* always AUTO */

int8_t nfft; /* can be AUTO */
int8_t guard; /* can be AUTO */

int8_t sb_conn_total_seg;
int8_t sb_wanted_seg;
int8_t sb_subchannel;

struct dibISDBTLayer {
int8_t nb_segments;
int8_t constellation;
int8_t code_rate;
int8_t time_intlv;
} layer[3];
} isdbt;
#endif

#ifdef CONFIG_STANDARD_DAB
struct dibDABChannel {
int8_t tmode;
uint8_t spectrum_inversion;
uint8_t nb_active_sub;
uint8_t reconfig;
int16_t cif_occurence_change;

struct dibDABsubChannel {
uint8_t subChid;
uint16_t start_address;
uint16_t sub_size;

uint8_t form;
uint8_t table_index;
uint8_t option;
uint8_t protection_level;

uint8_t is_ts;
uint8_t subc_new;
uint16_t addr_URAM;

uint8_t requested_fec;
uint8_t dummy0;
uint16_t dummy1; /* binary backward compat since size prev and start adress prev have been removed */

} subChannel[DAB_MAX_SUBC];
} dab;
#endif

#ifdef CONFIG_STANDARD_DVBT
struct dibDVBSHChannel {
struct dibDVBTChannel dvb_common;
int8_t dvb_sh;
int8_t common_mult;
int8_t nof_late_taps;
int8_t nof_slices;
int8_t slice_distance;
int8_t non_late_incr;
} dvbsh;

#endif

#ifdef CONFIG_STANDARD_ANALOG
struct dibANALOGChannel {
uint32_t TunerStandard;
uint32_t CountryCode;


uint32_t Cable;
} analog;
#endif

#ifdef CONFIG_STANDARD_ATSC
struct dibATSCChannel {
int8_t spectrum_inversion;
int8_t modulation;
} atsc;
#endif

struct dibCMMBChannel
{
int8_t nfft;
uint32_t config_changed_timestamp;
uint8_t parameters_changed; //Christophe doit un caf??Luc si le paramre change et devient "par time slot"
struct time_slot
{
struct channel_config
{
#define RS_CRATE_1 0
#define RS_CRATE_14_15 1
#define RS_CRATE_12_15 2
#define RS_CRATE_11_15 3
int8_t rs_code_rate; /* 0:240/240, 1:224/240, 2:192/240, 3:176/240 */
int8_t intlv_mode; /* 1:Mode 1, 2:Mode 2, 3:Mode 3 */
int8_t ldpc_cr; /* 0:1/2, 1:3/4 */
int8_t constellation; /* 0:BPSK, 1:QPSK, 2:16-QAM */
int8_t scrambling; /* 0:Mode 0, 1:Mode 1 ... 7:Mode 7 */
} parameters;
int8_t mf_id; /* MF_IF of MF this time slot is assigned to */
int8_t slot_mask;
} ts_array[40]; /* Physical layer level: Broadcast Channel Frame */
} cmmb;

struct dibMISC {
uint32_t pattern;
} misc;

} u;

// private information per frontend and per channel
struct dibChannelFEInfo
{
uint32_t tune_time_locked; /* the time it took for this frontend to acquired mpeg lock or sh lock */
uint32_t tune_time_data; /* the time it took for this frontend to receiver data */

uint32_t tune_start_time;
uint32_t tune_time_estimation[2];

uint32_t priv[11]; /* memory for a frontend to store some private about this channel */
} fe_info[MAX_NB_OF_FRONTENDS_IN_CHAIN];

struct dibChannelContext {
#define CHANNEL_STATUS_PARAMETERS_UNKNOWN 0x01
#define CHANNEL_STATUS_PARAMETERS_SET 0x02
uint8_t status;
uint32_t tune_time_estimation[2]; /* averaged real tuning time */
int tps_available;
uint16_t tps[9];
} context;

#define MAX_MONITORING_AGE 50000
#define MIN_MONITORING_REFRESH_RATE 500
struct dibChannelMonitor {
uint8_t refresh; /* internal field to request a refresh of the monitoring - used by the adapter */
uint32_t timestamp;


uint32_t adc_power;
uint16_t agc_global;
uint16_t agc_rf;
uint16_t agc_bb;

uint16_t agc_wbd; /* NV = AgcWbd/2^12 */
uint16_t agc_wbd_split; /* NV = AgcSplitOffset/2^8 */
uint32_t noise_power; /* Power of Noise - dB = 10*log10(noise_power/2^32) */
uint32_t signal_power; /* Power of Signal - dB = 10*log10(signal_power/2^32) */

uint8_t quality;
uint8_t quality_fast;


union {
struct {
uint32_t ber;
uint16_t packet_errors;
} dvbt;
struct {
uint16_t per;
} dvbsh;
struct {
uint32_t ber;
uint16_t packet_errors;
uint16_t dmb_lock_frame;

/* Not supported for now


uint8_t tmode;

uint16_t syn_fic;
uint16_t syn_msc;
uint16_t syn_subc;
uint16_t syn;
uint16_t syn_subid;

uint16_t fec_state;
uint8_t fec_subid[12];
*/
} dab;
struct {
uint32_t per;
uint32_t packet_error;
uint32_t syndrome_first_iter;
uint8_t time_slot_num;
/* [ 7] octopus ov | [ 6] octopus ov | [ 5] octopus ov | [ 4] octopus ov |
* [ 3] octopus ov | [ 2] octopus ov | [ 1] reflex in ov | [ 0] ldcp ov |
*/
uint8_t overflow;

} cmmb;

struct {
uint32_t ber[3];
uint16_t packet_errors[3];
} isdbt;
} u;
} fe_monitor[MAX_NB_OF_FRONTENDS_IN_CHAIN];


int chid_to_feid[MAX_NB_OF_FRONTENDS_IN_CHAIN];
};

#define CHANNEL_FE_INFO_PRIV_SIZE ( sizeof(((struct dibChannelFEInfo *) (NULL))->priv ) )


struct dibSignalQuality {
/* syndrome is used to compute the quality - syndrome is valid on the master only - in diversity */
uint8_t syndrome_is_set : 1; /* 0:not set, 1:set */
uint8_t synd_sample_count; // after x samples we are adding this one to the fir_filter
int16_t synd_mean;
int16_t synd_std;

uint8_t fir_synd_ptr;
int16_t fir_synd_mean[8];
int16_t fir_synd_std[8];
};
struct MsgHeader;
extern void channel_init(struct dibChannel *, uint8_t type);

[color=#FF0000][/color]struct dibChannelFEInfo * channel_frontend_info(struct dibChannel *, int id); //dibChannelFEInfo的声明
struct dibChannelMonitor * channel_frontend_monitoring(struct dibChannel *, int id);//dibChannelMonitor的声明



编译时,在其他文件中使用dibChannelMonitor、dibChannelMonitor地方
报错:
1>d:\documents and settings\dean\桌面\8093\8093\channel.cpp(578) : error C2027: 使用了未定义类型“dibChannelMonitor”
1> d:\documents and settings\dean\桌面\8093\8093\common.h(645) : 参见“dibChannelMonitor”的声明
1>d:\documents and settings\dean\桌面\8093\8093\channel.cpp(578) : error C2227: “->timestamp”的左边必须指向类/结构/联合/泛型类型
我把extern "C" 里面的复制到声明上面,原来的删除,编译通过,但链接是提示:1>dib0090.obj : error LNK2005: _fe_info 已经在 antenna.obj 中定义
1>dib0090.obj : error LNK2005: _fe_monitor 已经在 antenna.obj 中定义
等类似的错误,fe_monitor是dibChannelMonitor结构体变量,dibChannelFEInfo的情况完全一样,其他文件是包括了头文件common.h的


求帮助,搞的很久都搞不定。

[解决办法]
http://baike.baidu.com/view/2816461.htm

百科不是很详细吗
[解决办法]

探讨
引用:
不明白LZ问一个extern "c"贴这么多代码

这个是声明,被声明部分按照C语言方式编译和连接。一般在其他语言内嵌C使用

是在C++里使用C,但是用的时候要报错啊,说是未定义类型“dibChannelMonitor”,代码里面不是已经定义了吗?搞不懂啊

读书人网 >C++

热点推荐