gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 07:29:03 25 4
gpt4 key购买 nike

无论我在哪里包含某个commands.h 头文件,在commands.c 之外的任何地方,编译器都会抛出此错误。 commands.h 包含使用 instrument.h 中定义的结构的函数原型(prototype),特别是:

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_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 header 中编写一些定义,以便我的 instrument.c 文件可以访问,但如前所述,每次我包含 命令时。 h 在那里,编译器会产生该错误。我已经尝试在我的其他一些源文件中包含 commands.h,同样的事情不断发生。感谢您的帮助。

最佳答案

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

#ifndef COMMANDS_INCLUDED
#define COMMANDS_INCLUDED

#include "instrument.h"

//.. as you were

#endif

关于c++ - 预期的声明说明符或 '...' 之前的 'MLD_PACKET',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18083779/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com