本文介绍了用C的typedef stuct问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好
我面对我已经定义我的C头文件的结构一个奇怪的问题:

  typedef结构iRecActive {    焦炭iRecSID [32];
    unsigned char型RecStatus;
    INT curSel;} iRecAcitve_t;

但是当我在另一个文件中使用相同的结构,编译器无法识别的结构,即使我有双重检查,我已经包括它的头文件。以下是错误:

:错误C2065:iRecActive_t':未声明的标识符

以下是我所定义的结构文件的完整code

 的#ifndef _TS_HTTP_APPLICATION_H_
#定义_TS_HTTP_APPLICATION_H_#IFDEF __cplusplus
为externC
{
#万一typedef结构iRecActive {    焦炭iRecSID [32];
    unsigned char型RecStatus;
    INT curSel;} iRecAcitve_t;INT startHTTPServer(INT HTMLserverPort);
INT closeHTTPServer();INT openTS_SegmenterN();
无效pushTSDataN(无符号字符* TSData,INT LEN);
无效closeTS_SegmenterN();无效removeAllConnections();#IFDEF __cplusplus
}
#万一#万一


解决方案

改变 iRecAcitve_t iRecActive_t

Hello thereI am facing a weird problem I have defined I a structure in a C header file:

typedef struct iRecActive{

    char iRecSID[32];
    unsigned char RecStatus;
    int curSel;

}iRecAcitve_t;

but when I use the same structure in another file, the compiler doesn't recognize the structure even though I have double checked that I have included its header file. Following is the error :

: error C2065: 'iRecActive_t' : undeclared identifier

Following is the full code of the file where I have defined the structure

#ifndef _TS_HTTP_APPLICATION_H_
#define _TS_HTTP_APPLICATION_H_

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct iRecActive{

    char iRecSID[32];
    unsigned char RecStatus;
    int curSel;

}iRecAcitve_t;

int startHTTPServer(int HTMLserverPort);
int closeHTTPServer();

int openTS_SegmenterN();
void pushTSDataN(unsigned char* TSData, int len);
void closeTS_SegmenterN();

void removeAllConnections();

#ifdef __cplusplus
}
#endif

#endif
解决方案

change iRecAcitve_t to iRecActive_t.

这篇关于用C的typedef stuct问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 03:22