mita icon indicating copy to clipboard operation
mita copied to clipboard

enum in struct

Open boaks opened this issue 5 years ago • 2 comments

enum Feature {
    Temperature,
    Pressure,
    Humidity,
    Illuminance,
    Accelerometer,
    Gyroscope,
    Magnetometer
}

struct Sensor {
	var current : float;
	var min : float;
	var max : float;
	var init : bool;
	var feature : Feature;
}

Results in

typedef struct {
	float current;
	float min;
	float max;
	bool init;
	Feature feature;
} Sensor;

typedef enum {
	Temperature,
	Pressure,
	Humidity,
	Illuminance,
	Accelerometer,
	Gyroscope,
	Magnetometer
} Feature;

and error: "unknown type name 'Feature'"

boaks avatar Aug 16 '19 10:08 boaks

~~This chould already be fixed in master since some point after the new type system. Are you using master or the XDK Workbench 3.*?~~ Nope, not fixed.

wegendt-bosch avatar Sep 05 '19 06:09 wegendt-bosch

We might have to do something similar to how we handle system resource initialization and create a graph of dependencies, then do a topological sort.

Since structs may reference one another via references, those have to be excluded when collecting dependencies, and forward declared when translating.

wegendt-bosch avatar Oct 07 '19 06:10 wegendt-bosch