0

无论我在哪里包含某个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_CONFIGPSTATPLUS_STATE如此定义,在instrument.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在我的其他一些源文件中包含,同样的事情一直在发生。任何帮助表示赞赏。

4

2 回答 2

1

制作你的commands.h #include "instrument.h",因为它需要那里的东西否则PSTATPLUS_CONFIGPSTATPLUS_STATE导致错误。

#ifndef COMMANDS_INCLUDED
#define COMMANDS_INCLUDED

#include "instrument.h"

//.. as you were

#endif
于 2013-08-06T15:07:17.603 回答
0

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

于 2013-08-06T15:07:25.203 回答