解析 RapidJSON 时出错的地方
Where the error come while parsing RapidJSON
我正在尝试使用 RapidJSON 解析一个 JSON 文件,我创建了这段代码来获取整数(在本例中),但是,我收到错误消息说一些变量在被包含时不是结构的成员。声明的结构是原始 JSON 格式,但格式化为结构以获取值。
struct MessageHeader
{
int protocolVersion;
int messageID;
int stationID;
};
struct MessageCam
{
int generationDeltaTime;
struct MessageCamParameters
{
struct MessageBasicContainer
{
int stationType;
struct MessageReferencePosition
{
int latitude;
int longitude;
struct MessagePositionConfidenceEllipse
{
int semiMajorConfidence;
int semiMinorConfidence;
int semiMajorOrientation;
};
struct MessageAltitude
{
int altitudeValue;
int altitudeConfidence;
};
};
};
struct MessageHighFrequencyContainer
{
struct MessageBasicVehicleContainerHighFrequency
{
struct MessageHeading
{
int headingValue;
int headingConfidence;
};
struct MessageSpeed
{
int speedValue;
int speedConfidence;
};
int driveDirection;
struct MessageVehicleLength
{
int vehicleLengthValue;
int vehicleLengthConfidenceIndication;
};
int vehicleWidth;
struct MessageLongitudinalAcceleration
{
int longitudinalAccelerationValue;
int longitudinalAccelerationConfidence;
};
struct MessageCurvature
{
int curvatureValue;
int curvatureConfidence;
};
int curvatureCalculationMode;
struct MessageYawRate
{
int yawRateValue;
int yawRateConfidence;
};
};
};
};
};
vanetza::asn1::Cam message;
doc.Parse(pr);
const auto& header = doc["header"];
MessageHeader messageHeader;
messageHeader.protocolVersion = header["protocolVersion"].GetInt();
messageHeader.messageID = header["messageID"].GetInt();
messageHeader.stationID = header["stationID"].GetInt();
const auto& cam = doc["cam"];
MessageCam messageCam;
messageCam.generationDeltaTime = cam["generationDeltaTime"].GetInt();
const auto& camParameters = cam["camParameters"];
MessageCamParameters messageCamParameters;
const auto& basicContainer = camParameters["basicContainer"];
MessageBasicContainer messageBasicContainer;
messageBasicContainer.stationType = basicContainer["stationType"].GetInt();
const auto& referencePosition = basicContainer["referencePosition"];
MessageReferencePosition messageReferencePosition;
messageReferencePosition.latitude = referencePosition["latitude"].GetInt();
messageReferencePosition.longitude = referencePosition["longitude"].GetInt();
const auto& positionConfidenceEllipse = referencePosition["positionConfidenceEllipse"];
MessagePositionConfidenceEllipse messagePositionConfidenceEllipse;
messagePositionConfidenceEllipse.semiMajorConfidence = positionConfidenceEllipse["semiMajorConfidence"].GetInt();
messagePositionConfidenceEllipse.semiMinorConfidence = positionConfidenceEllipse["semiMinorConfidence"].GetInt();
messagePositionConfidenceEllipse.semiMajorOrientation = positionConfidenceEllipse["semiMajorOrientation"].GetInt();
const auto& altitude = basicContainer["altitude"];
MessageAltitude messageAltitude;
messageAltitude.altitudeValue = altitude["altitudeValue"].GetInt();
messageAltitude.altitudeConfidence = altitude["altitudeConfidence"].GetInt();
const auto& highFrequencyContainer = camParameters["highFrequencyContainer"];
MessageHighFrequencyContainer messageHighFrequencyContainer;
const auto& basicVehicleContainerHighFrequency = highFrequencyContainer["basicVehicleContainerHighFrequency"];
MessageBasicVehicleContainerHighFrequency messageBasicVehicleContainerHighFrequency;
const auto& heading = basicVehicleContainerHighFrequency["heading"];
MessageHeading messageHeading;
messageHeading.headingValue = heading["headingValue"].GetInt();
messageHeading.headingConfidence = heading["heading"]["headingConfidence"].GetInt();
const auto& speed = basicVehicleContainerHighFrequency["speed"];
MessageSpeed messageSpeed;
messageSpeed.speedValue = speed["speedValue"].GetInt();
messageSpeed.speedConfidence = speed["speedConfidence"].GetInt();
messageBasicVehicleContainerHighFrequency.driveDirection = basicVehicleContainerHighFrequency["driveDirection"].GetInt();
const auto& vehicleLength = basicVehicleContainerHighFrequency["vehicleLength"];
MessageVehicleLength messageVehicleLength;
messageVehicleLength.vehicleLengthValue = vehicleLength["vehicleLengthValue"].GetInt();
messageVehicleLength.vehicleLengthConfidenceIndication = vehicleLength["vehicleLengthConfidenceIndication"].GetInt();
messageBasicVehicleContainerHighFrequency.vehicleWidth = basicVehicleContainerHighFrequency["vehicleWidth"].GetInt();
const auto& longitudinalAcceleration = basicVehicleContainerHighFrequency["longitudinalAcceleration"];
MessageLongitudinalAcceleration messageLongitudinalAcceleration;
messageLongitudinalAcceleration.longitudinalAccelerationValue = longitudinalAcceleration["longitudinalAccelerationValue"].GetInt();
messageLongitudinalAcceleration.longitudinalAccelerationConfidence = longitudinalAcceleration["longitudinalAccelerationConfidence"].GetInt();
const auto& curvature = basicVehicleContainerHighFrequency["curvature"];
MessageCurvature messageCurvature;
messageCurvature.curvatureValue = curvature["curvatureValue"].GetInt();
messageCurvature.curvatureConfidence = curvature["curvatureConfidence"].GetInt();
messageBasicVehicleContainerHighFrequency.curvatureCalculationMode = basicVehicleContainerHighFrequency["curvatureCalculationMode"].GetInt();
const auto& yawRate = basicVehicleContainerHighFrequency["yawRate"];
MessageYawRate messageYawRate;
messageYawRate.yawRateValue = yawRate["yawRateValue"].GetInt();
messageYawRate.yawRateConfidence = yawRate["yawRateConfidence"].GetInt();
但是,我得到了这些错误:
cpp:479:5: error: ‘MessageCamParameters’ was not declared in this scope; did you mean ‘CamParameters’?
479 | MessageCamParameters messageCamParameters;
| ^~~~~~~~~~~~~~~~~~~~
| CamParameters
cpp:481:5: error: ‘MessageBasicContainer’ was not declared in this scope; did you mean ‘BasicContainer’?
481 | MessageBasicContainer messageBasicContainer;
| ^~~~~~~~~~~~~~~~~~~~~
| BasicContainer
cpp:482:5: error: ‘messageBasicContainer’ was not declared in this scope; did you mean ‘BasicContainer’?
482 | messageBasicContainer.stationType = basicContainer["stationType"].GetInt();
| ^~~~~~~~~~~~~~~~~~~~~
| BasicContainer
cpp:485:5: error: ‘MessageReferencePosition’ was not declared in this scope; did you mean ‘DeltaReferencePosition’?
485 | MessageReferencePosition messageReferencePosition;
| ^~~~~~~~~~~~~~~~~~~~~~~~
| DeltaReferencePosition
cpp:486:5: error: ‘messageReferencePosition’ was not declared in this scope; did you mean ‘DeltaReferencePosition’?
486 | messageReferencePosition.latitude = referencePosition["latitude"].GetInt();
| ^~~~~~~~~~~~~~~~~~~~~~~~
| DeltaReferencePosition
cpp:491:5: error: ‘MessagePositionConfidenceEllipse’ was not declared in this scope; did you mean ‘positionConfidenceEllipse’?
491 | MessagePositionConfidenceEllipse messagePositionConfidenceEllipse;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| positionConfidenceEllipse
cpp:492:5: error: ‘messagePositionConfidenceEllipse’ was not declared in this scope; did you mean ‘positionConfidenceEllipse’?
492 | messagePositionConfidenceEllipse.semiMajorConfidence = positionConfidenceEllipse["semiMajorConfidence"].GetInt();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| positionConfidenceEllipse
cpp:498:5: error: ‘MessageAltitude’ was not declared in this scope; did you mean ‘DeltaAltitude’?
498 | MessageAltitude messageAltitude;
| ^~~~~~~~~~~~~~~
| DeltaAltitude
cpp:499:5: error: ‘messageAltitude’ was not declared in this scope; did you mean ‘DeltaAltitude’?
499 | messageAltitude.altitudeValue = altitude["altitudeValue"].GetInt();
| ^~~~~~~~~~~~~~~
| DeltaAltitude
cpp:509:5: error: ‘MessageHighFrequencyContainer’ was not declared in this scope; did you mean ‘HighFrequencyContainer’?
509 | MessageHighFrequencyContainer messageHighFrequencyContainer;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| HighFrequencyContainer
cpp:511:5: error: ‘MessageBasicVehicleContainerHighFrequency’ was not declared in this scope; did you mean ‘BasicVehicleContainerHighFrequency’?
511 | MessageBasicVehicleContainerHighFrequency messageBasicVehicleContainerHighFrequency;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| BasicVehicleContainerHighFrequency
cpp:513:5: error: ‘MessageHeading’ was not declared in this scope; did you mean ‘MessageHeader’?
513 | MessageHeading messageHeading;
| ^~~~~~~~~~~~~~
| MessageHeader
cpp:514:5: error: ‘messageHeading’ was not declared in this scope; did you mean ‘messageHeader’?
514 | messageHeading.headingValue = heading["headingValue"].GetInt();
| ^~~~~~~~~~~~~~
| messageHeader
cpp:517:5: error: ‘MessageSpeed’ was not declared in this scope
517 | MessageSpeed messageSpeed;
| ^~~~~~~~~~~~
cpp:518:5: error: ‘messageSpeed’ was not declared in this scope
518 | messageSpeed.speedValue = speed["speedValue"].GetInt();
| ^~~~~~~~~~~~
cpp:521:5: error: ‘messageBasicVehicleContainerHighFrequency’ was not declared in this scope; did you mean ‘BasicVehicleContainerHighFrequency’?
521 | messageBasicVehicleContainerHighFrequency.driveDirection = basicVehicleContainerHighFrequency["driveDirection"].GetInt();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| BasicVehicleContainerHighFrequency
cpp:524:5: error: ‘MessageVehicleLength’ was not declared in this scope; did you mean ‘VehicleLength’?
524 | MessageVehicleLength messageVehicleLength;
| ^~~~~~~~~~~~~~~~~~~~
| VehicleLength
cpp:525:5: error: ‘messageVehicleLength’ was not declared in this scope; did you mean ‘VehicleLength’?
525 | messageVehicleLength.vehicleLengthValue = vehicleLength["vehicleLengthValue"].GetInt();
| ^~~~~~~~~~~~~~~~~~~~
| VehicleLength
cpp:531:5: error: ‘MessageLongitudinalAcceleration’ was not declared in this scope; did you mean ‘LongitudinalAcceleration’?
531 | MessageLongitudinalAcceleration messageLongitudinalAcceleration;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| LongitudinalAcceleration
cpp:532:5: error: ‘messageLongitudinalAcceleration’ was not declared in this scope; did you mean ‘LongitudinalAcceleration’?
532 | messageLongitudinalAcceleration.longitudinalAccelerationValue = longitudinalAcceleration["longitudinalAccelerationValue"].GetInt();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| LongitudinalAcceleration
cpp:536:6: error: ‘MessageCurvature’ was not declared in this scope
536 | MessageCurvature messageCurvature;
| ^~~~~~~~~~~~~~~~
cpp:537:5: error: ‘messageCurvature’ was not declared in this scope
537 | messageCurvature.curvatureValue = curvature["curvatureValue"].GetInt();
| ^~~~~~~~~~~~~~~~
cpp:543:5: error: ‘MessageYawRate’ was not declared in this scope
543 | MessageYawRate messageYawRate;
| ^~~~~~~~~~~~~~
cpp:544:5: error: ‘messageYawRate’ was not declared in this scope
544 | messageYawRate.yawRateValue = yawRate["yawRateValue"].GetInt();
| ^~~~~~~~~~~~~~
结构定义有问题吗?
struct MessageCam
{
int generationDeltaTime;
struct MessageCamParameters
{
MessageCamParameters
被声明为 MessageCam
的成员。当您在另一个 class.
中声明一个 class 时,这就是 C++ 中发生的情况
MessageCamParameters messageCamParameters;
这试图定义类型 MessageCamParameters
的对象。您没有声明 class 或名为 MessageCamParameters
的结构。您将那个名字的 class 声明为另一个 class 的成员 。因此,在这种情况下,要正确引用它,应该是:
MessageCam::MessageCamParameters messageCamParameters;
如果您不想将此 class 声明为另一个 class 的成员,因此它是一个普通的普通品种 MessageCamParameters
那么,好吧,不要去做。不要将 class 声明为另一个 class.
的成员
我正在尝试使用 RapidJSON 解析一个 JSON 文件,我创建了这段代码来获取整数(在本例中),但是,我收到错误消息说一些变量在被包含时不是结构的成员。声明的结构是原始 JSON 格式,但格式化为结构以获取值。
struct MessageHeader
{
int protocolVersion;
int messageID;
int stationID;
};
struct MessageCam
{
int generationDeltaTime;
struct MessageCamParameters
{
struct MessageBasicContainer
{
int stationType;
struct MessageReferencePosition
{
int latitude;
int longitude;
struct MessagePositionConfidenceEllipse
{
int semiMajorConfidence;
int semiMinorConfidence;
int semiMajorOrientation;
};
struct MessageAltitude
{
int altitudeValue;
int altitudeConfidence;
};
};
};
struct MessageHighFrequencyContainer
{
struct MessageBasicVehicleContainerHighFrequency
{
struct MessageHeading
{
int headingValue;
int headingConfidence;
};
struct MessageSpeed
{
int speedValue;
int speedConfidence;
};
int driveDirection;
struct MessageVehicleLength
{
int vehicleLengthValue;
int vehicleLengthConfidenceIndication;
};
int vehicleWidth;
struct MessageLongitudinalAcceleration
{
int longitudinalAccelerationValue;
int longitudinalAccelerationConfidence;
};
struct MessageCurvature
{
int curvatureValue;
int curvatureConfidence;
};
int curvatureCalculationMode;
struct MessageYawRate
{
int yawRateValue;
int yawRateConfidence;
};
};
};
};
};
vanetza::asn1::Cam message;
doc.Parse(pr);
const auto& header = doc["header"];
MessageHeader messageHeader;
messageHeader.protocolVersion = header["protocolVersion"].GetInt();
messageHeader.messageID = header["messageID"].GetInt();
messageHeader.stationID = header["stationID"].GetInt();
const auto& cam = doc["cam"];
MessageCam messageCam;
messageCam.generationDeltaTime = cam["generationDeltaTime"].GetInt();
const auto& camParameters = cam["camParameters"];
MessageCamParameters messageCamParameters;
const auto& basicContainer = camParameters["basicContainer"];
MessageBasicContainer messageBasicContainer;
messageBasicContainer.stationType = basicContainer["stationType"].GetInt();
const auto& referencePosition = basicContainer["referencePosition"];
MessageReferencePosition messageReferencePosition;
messageReferencePosition.latitude = referencePosition["latitude"].GetInt();
messageReferencePosition.longitude = referencePosition["longitude"].GetInt();
const auto& positionConfidenceEllipse = referencePosition["positionConfidenceEllipse"];
MessagePositionConfidenceEllipse messagePositionConfidenceEllipse;
messagePositionConfidenceEllipse.semiMajorConfidence = positionConfidenceEllipse["semiMajorConfidence"].GetInt();
messagePositionConfidenceEllipse.semiMinorConfidence = positionConfidenceEllipse["semiMinorConfidence"].GetInt();
messagePositionConfidenceEllipse.semiMajorOrientation = positionConfidenceEllipse["semiMajorOrientation"].GetInt();
const auto& altitude = basicContainer["altitude"];
MessageAltitude messageAltitude;
messageAltitude.altitudeValue = altitude["altitudeValue"].GetInt();
messageAltitude.altitudeConfidence = altitude["altitudeConfidence"].GetInt();
const auto& highFrequencyContainer = camParameters["highFrequencyContainer"];
MessageHighFrequencyContainer messageHighFrequencyContainer;
const auto& basicVehicleContainerHighFrequency = highFrequencyContainer["basicVehicleContainerHighFrequency"];
MessageBasicVehicleContainerHighFrequency messageBasicVehicleContainerHighFrequency;
const auto& heading = basicVehicleContainerHighFrequency["heading"];
MessageHeading messageHeading;
messageHeading.headingValue = heading["headingValue"].GetInt();
messageHeading.headingConfidence = heading["heading"]["headingConfidence"].GetInt();
const auto& speed = basicVehicleContainerHighFrequency["speed"];
MessageSpeed messageSpeed;
messageSpeed.speedValue = speed["speedValue"].GetInt();
messageSpeed.speedConfidence = speed["speedConfidence"].GetInt();
messageBasicVehicleContainerHighFrequency.driveDirection = basicVehicleContainerHighFrequency["driveDirection"].GetInt();
const auto& vehicleLength = basicVehicleContainerHighFrequency["vehicleLength"];
MessageVehicleLength messageVehicleLength;
messageVehicleLength.vehicleLengthValue = vehicleLength["vehicleLengthValue"].GetInt();
messageVehicleLength.vehicleLengthConfidenceIndication = vehicleLength["vehicleLengthConfidenceIndication"].GetInt();
messageBasicVehicleContainerHighFrequency.vehicleWidth = basicVehicleContainerHighFrequency["vehicleWidth"].GetInt();
const auto& longitudinalAcceleration = basicVehicleContainerHighFrequency["longitudinalAcceleration"];
MessageLongitudinalAcceleration messageLongitudinalAcceleration;
messageLongitudinalAcceleration.longitudinalAccelerationValue = longitudinalAcceleration["longitudinalAccelerationValue"].GetInt();
messageLongitudinalAcceleration.longitudinalAccelerationConfidence = longitudinalAcceleration["longitudinalAccelerationConfidence"].GetInt();
const auto& curvature = basicVehicleContainerHighFrequency["curvature"];
MessageCurvature messageCurvature;
messageCurvature.curvatureValue = curvature["curvatureValue"].GetInt();
messageCurvature.curvatureConfidence = curvature["curvatureConfidence"].GetInt();
messageBasicVehicleContainerHighFrequency.curvatureCalculationMode = basicVehicleContainerHighFrequency["curvatureCalculationMode"].GetInt();
const auto& yawRate = basicVehicleContainerHighFrequency["yawRate"];
MessageYawRate messageYawRate;
messageYawRate.yawRateValue = yawRate["yawRateValue"].GetInt();
messageYawRate.yawRateConfidence = yawRate["yawRateConfidence"].GetInt();
但是,我得到了这些错误:
cpp:479:5: error: ‘MessageCamParameters’ was not declared in this scope; did you mean ‘CamParameters’?
479 | MessageCamParameters messageCamParameters;
| ^~~~~~~~~~~~~~~~~~~~
| CamParameters
cpp:481:5: error: ‘MessageBasicContainer’ was not declared in this scope; did you mean ‘BasicContainer’?
481 | MessageBasicContainer messageBasicContainer;
| ^~~~~~~~~~~~~~~~~~~~~
| BasicContainer
cpp:482:5: error: ‘messageBasicContainer’ was not declared in this scope; did you mean ‘BasicContainer’?
482 | messageBasicContainer.stationType = basicContainer["stationType"].GetInt();
| ^~~~~~~~~~~~~~~~~~~~~
| BasicContainer
cpp:485:5: error: ‘MessageReferencePosition’ was not declared in this scope; did you mean ‘DeltaReferencePosition’?
485 | MessageReferencePosition messageReferencePosition;
| ^~~~~~~~~~~~~~~~~~~~~~~~
| DeltaReferencePosition
cpp:486:5: error: ‘messageReferencePosition’ was not declared in this scope; did you mean ‘DeltaReferencePosition’?
486 | messageReferencePosition.latitude = referencePosition["latitude"].GetInt();
| ^~~~~~~~~~~~~~~~~~~~~~~~
| DeltaReferencePosition
cpp:491:5: error: ‘MessagePositionConfidenceEllipse’ was not declared in this scope; did you mean ‘positionConfidenceEllipse’?
491 | MessagePositionConfidenceEllipse messagePositionConfidenceEllipse;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| positionConfidenceEllipse
cpp:492:5: error: ‘messagePositionConfidenceEllipse’ was not declared in this scope; did you mean ‘positionConfidenceEllipse’?
492 | messagePositionConfidenceEllipse.semiMajorConfidence = positionConfidenceEllipse["semiMajorConfidence"].GetInt();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| positionConfidenceEllipse
cpp:498:5: error: ‘MessageAltitude’ was not declared in this scope; did you mean ‘DeltaAltitude’?
498 | MessageAltitude messageAltitude;
| ^~~~~~~~~~~~~~~
| DeltaAltitude
cpp:499:5: error: ‘messageAltitude’ was not declared in this scope; did you mean ‘DeltaAltitude’?
499 | messageAltitude.altitudeValue = altitude["altitudeValue"].GetInt();
| ^~~~~~~~~~~~~~~
| DeltaAltitude
cpp:509:5: error: ‘MessageHighFrequencyContainer’ was not declared in this scope; did you mean ‘HighFrequencyContainer’?
509 | MessageHighFrequencyContainer messageHighFrequencyContainer;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| HighFrequencyContainer
cpp:511:5: error: ‘MessageBasicVehicleContainerHighFrequency’ was not declared in this scope; did you mean ‘BasicVehicleContainerHighFrequency’?
511 | MessageBasicVehicleContainerHighFrequency messageBasicVehicleContainerHighFrequency;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| BasicVehicleContainerHighFrequency
cpp:513:5: error: ‘MessageHeading’ was not declared in this scope; did you mean ‘MessageHeader’?
513 | MessageHeading messageHeading;
| ^~~~~~~~~~~~~~
| MessageHeader
cpp:514:5: error: ‘messageHeading’ was not declared in this scope; did you mean ‘messageHeader’?
514 | messageHeading.headingValue = heading["headingValue"].GetInt();
| ^~~~~~~~~~~~~~
| messageHeader
cpp:517:5: error: ‘MessageSpeed’ was not declared in this scope
517 | MessageSpeed messageSpeed;
| ^~~~~~~~~~~~
cpp:518:5: error: ‘messageSpeed’ was not declared in this scope
518 | messageSpeed.speedValue = speed["speedValue"].GetInt();
| ^~~~~~~~~~~~
cpp:521:5: error: ‘messageBasicVehicleContainerHighFrequency’ was not declared in this scope; did you mean ‘BasicVehicleContainerHighFrequency’?
521 | messageBasicVehicleContainerHighFrequency.driveDirection = basicVehicleContainerHighFrequency["driveDirection"].GetInt();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| BasicVehicleContainerHighFrequency
cpp:524:5: error: ‘MessageVehicleLength’ was not declared in this scope; did you mean ‘VehicleLength’?
524 | MessageVehicleLength messageVehicleLength;
| ^~~~~~~~~~~~~~~~~~~~
| VehicleLength
cpp:525:5: error: ‘messageVehicleLength’ was not declared in this scope; did you mean ‘VehicleLength’?
525 | messageVehicleLength.vehicleLengthValue = vehicleLength["vehicleLengthValue"].GetInt();
| ^~~~~~~~~~~~~~~~~~~~
| VehicleLength
cpp:531:5: error: ‘MessageLongitudinalAcceleration’ was not declared in this scope; did you mean ‘LongitudinalAcceleration’?
531 | MessageLongitudinalAcceleration messageLongitudinalAcceleration;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| LongitudinalAcceleration
cpp:532:5: error: ‘messageLongitudinalAcceleration’ was not declared in this scope; did you mean ‘LongitudinalAcceleration’?
532 | messageLongitudinalAcceleration.longitudinalAccelerationValue = longitudinalAcceleration["longitudinalAccelerationValue"].GetInt();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| LongitudinalAcceleration
cpp:536:6: error: ‘MessageCurvature’ was not declared in this scope
536 | MessageCurvature messageCurvature;
| ^~~~~~~~~~~~~~~~
cpp:537:5: error: ‘messageCurvature’ was not declared in this scope
537 | messageCurvature.curvatureValue = curvature["curvatureValue"].GetInt();
| ^~~~~~~~~~~~~~~~
cpp:543:5: error: ‘MessageYawRate’ was not declared in this scope
543 | MessageYawRate messageYawRate;
| ^~~~~~~~~~~~~~
cpp:544:5: error: ‘messageYawRate’ was not declared in this scope
544 | messageYawRate.yawRateValue = yawRate["yawRateValue"].GetInt();
| ^~~~~~~~~~~~~~
结构定义有问题吗?
struct MessageCam
{
int generationDeltaTime;
struct MessageCamParameters
{
MessageCamParameters
被声明为 MessageCam
的成员。当您在另一个 class.
MessageCamParameters messageCamParameters;
这试图定义类型 MessageCamParameters
的对象。您没有声明 class 或名为 MessageCamParameters
的结构。您将那个名字的 class 声明为另一个 class 的成员 。因此,在这种情况下,要正确引用它,应该是:
MessageCam::MessageCamParameters messageCamParameters;
如果您不想将此 class 声明为另一个 class 的成员,因此它是一个普通的普通品种 MessageCamParameters
那么,好吧,不要去做。不要将 class 声明为另一个 class.