'MLD_PACKET'之前的预期声明说明符或'...'

时间:2013-08-06 15:01:05

标签: c++ c

除了commands.h之外的任何地方,只要我包含某个commands.c头文件,编译器就会抛出此错误。 commands.h包含使用instrument.h中定义的结构的函数原型,具体为:

void readConfig(PSTATPLUS_CONFIG* pStatConfig_p, MLD_PACKET* rxPacketUart2_p);
void readState(PSTATPLUS_STATE* pStatState_p, MLD_PACKET* rxPacketUart2_p);
void writeConfig(PSTATPLUS_CONFIG* pStatConfig_p, MLD_PACKET* rxPacketUart2_p);
void writeState(PSTATPLUS_STATE* pStatState_p, MLD_PACKET* rxPacketUart2_p);
PSTATPLUS_CONFIG

PSTATPLUS_STATEinstrument.h定义如此:

typedef struct {
    float signalAmplitude;      // Signal Amplitude
    float signalOffset;         // Signal Offset
    unsigned char waveType;     // Waveform Type
    float startFreq;            // Frequency Start
    float stopFreq;             // Frequency Stop
    unsigned int numIncrements; // Number of Increments
    unsigned char scale;        // Linear(0) or log(1)
    float stepDelay;            // Step Delay
}PSTATPLUS_CONFIG;

typedef struct {    // Current biosensor status
    unsigned char scan;     // Scan status (on/off)
    unsigned char sample;   // Sample status (on/off)
    unsigned int currentIncrement; // Current scan increment
    unsigned char gain;     // Current gain setting
    float iValue;           // I voltage
    float qValue;           // Q voltage
    unsigned int sampleDivider; // 1 takes every ADC sample, 2 takes every 2nd ADC sample, 3 takes every 3rd ADC samp... n takes every nth. 0 stops data collection.
    unsigned int totalSamples;  // total number of samples wanted to complete one measurement.
}PSTATPLUS_STATE;

我需要在commands.h标头中编写一些可以访问instrument.c文件的定义,但如上所述,每次我在其中包含commands.h时,编译器都会产生该错误。我已经尝试在我的其他一些源文件中包含commands.h,同样的事情不断发生。任何帮助表示赞赏。

2 个答案:

答案 0 :(得分:1)

制作您的commands.h #include "instrument.h",因为它需要其他内容,否则PSTATPLUS_CONFIGPSTATPLUS_STATE会导致错误。

#ifndef COMMANDS_INCLUDED
#define COMMANDS_INCLUDED

#include "instrument.h"

//.. as you were

#endif

答案 1 :(得分:0)

看起来编译器认为MLD_PACKET是一个参数而不是类型。您还应该在使用它之前包含它的定义或声明。前进至少宣布它。