Aufruf eines Structs

OP #4679077
Lesenswert?

Hallo liebe Community,

wieso funktioniert folgender Aufruf nicht?


In der cpp-Datei

bool Configuration :: DMX_Config_method ( Configuration* 
DMX_Config_struct ) {

    DMX_Config_struct -> DMX_Config.baudrate = 250000;

    return true;
};

In der h-Datei

#ifndef CONFIGURATION_H_
#define CONFIGURATION_H_

#include "mbed.h"

class Configuration {

    private:

    public:

    Configuration ( void );
    ~ Configuration ( void );

    bool DMX_Config_method ( Configuration* DMX_Config_struct );

    struct DMX_Config {

        unsigned int baudrate;
        unsigned int bits;
        unsigned int stopbits;

        SerialBase :: Parity parity;

        PinName pin_RX;
        PinName pin_TX;
    };
};

#endif


Error:Error: Type name is not allowed in 
"Configuration/Configuration.cpp", Line: 11, Col: 27



LG Christian
Moderator Persönliche Seite #4679094
Lesenswert?

Christian K. schrieb:
> struct DMX_Config {
>
>         unsigned int baudrate;
>         unsigned int bits;
>         unsigned int stopbits;
>
>         SerialBase :: Parity parity;
>
>         PinName pin_RX;
>         PinName pin_TX;
>     };

Falsch. Richtig wäre:

    struct {

        unsigned int baudrate;
        unsigned int bits;
        unsigned int stopbits;

        SerialBase :: Parity parity;

        PinName pin_RX;
        PinName pin_TX;
    } DMX_Config;

Dann klappt das auch mit

    DMX_Config_struct -> DMX_Config.baudrate = 250000;

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren