I have this simple C code, but including the reference variable input parameter in the write and read functions makes the program not compile. If I remove &, the program is fine. I am running this on Microsoft Visual Studio 2017.
#include <stdio.h>
#include <stdint.h>
typedef struct Cr Cr;
typedef struct Modulation_format_cnfg Modulation_format_cnfg;
struct Modulation_format_cnfg {
union {
struct
{
uint32_t sc0 : 3;
uint32_t : 5;
uint32_t sc1 : 3;
uint32_t : 5;
uint32_t sc2 : 3;
uint32_t : 5;
uint32_t sc3 : 3;
uint32_t : 5;
};
uint32_t raw;
};
};
struct Cr
{
uint32_t const kBlock_base_addr;
Modulation_format_cnfg volatile modulation_format_cnfg;
};
void write(volatile Modulation_format_cnfg& r, const int val) {
r.raw = val;
}
uint32_t read(Modulation_format_cnfg volatile& r, const int val) {
return r.raw;
}
Cr cr[2];
Can somebody please help?
Thanks in advance!