0

i made a code but has errors and wan't able to solve them:-

the following errors are in one of mine header file(code shown below)

error C2143:syntax error : missing ';' before '*'

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Header file code:-

#ifndef _DEVICE_SOURCE_FICARD_HH
#define _DEVICE_SOURCE_FICARD_HH

#ifndef _FRAMED_SOURCE_HH
#include "FramedSource.hh"
#endif

#include <DeviceSource.hh>

typedef struct LtagBufferEntry
{
  char *pBuffer;
  struct LtagBufferEntry *pNext;
} LBufferEntry;

class FICardDeviceParameters {
public:
    (RetEntry*)(*p_lm_lock_fn)( void *data );  //error at this line
    void (*p_lm_unlock_fn)( void *data );
    int nFICardFrameSize;
  //%%% TO BE WRITTEN %%%
};

class DeviceSourceFICard: public DeviceSource {
public:
  static DeviceSourceFICard* createNew(UsageEnvironment& env, FICardDeviceParameters fi_params,
                 DeviceParameters params);

protected:
  DeviceSourceFICard(UsageEnvironment& env, FICardDeviceParameters fi_params, DeviceParameters params);
  // called only by createNew(), or by subclass constructors
  virtual ~DeviceSourceFICard();

private:
  // redefined virtual functions:
  virtual void doGetNextFrame();

private:
  void deliverFrame();

private:
  DeviceParameters fParams;
  LBufferEntry *pData;
  char         * pRetData;
  //int nFICardFrameSize;
  FICardDeviceParameters fiParams;
};

#endif //_DEVICE_SOURCE_FICARD_HH

Defination of RetEntry:-

typedef struct tagRetBuffer
{
  char *pBuffer;
  int nDataLn;
} RetEntry;

void InitBufferHandling();
void TransferBuffer( void *pBuffer );
RetEntry *lm_lock_fn( void *data );
void lm_unlock_fn( void *data );
int initLm555Settings(void);
void play();
void afterPlaying(void*);
void init_play();
void StartRTPProcess(void);

How to fix them...

4

1 回答 1

0

The problem is that the compiler does not know what RetEntry is in the expression:

(RetEntry*)(*p_lm_lock_fn)( void *data );

You must either include the header that provides the definition or else declare it in your current header. From the code below it seems to be a typedef to tagRetBuffer, so to declare it in the current translation unit you will need to declare the struct and the typedef:

struct tagRetBuffer;
typedef tagRetBuffer RetEntry;

Now, I would suggest that you avoid those typedef's altogether, in C++ the compiler will search for types if needed. You can just do:

struct RetEntry
{
  char *pBuffer;
  int nDataLn;
};

And then use RetEntry anywhere as if it was a typedef'ed name. Note that there are differences, but that in 99% of the cases you will not notice. And when you do notice it might even be to your advantage (for example, you cannot declare a typedef, so you need to declare the typedef'ed name and then redefine the typedef as per the first suggestion here).

于 2012-04-24T12:40:30.533 回答