Getting an initializer element is not constant
compile error when using avr-gcc. Is there any good way to do what I'm trying to do here?
file.c
#include "file.h"
#include "../notes/octave_two_notes.h"
//F2 is defined in octave_two_notes.h
//This is the file giving me the compilation error
struct Song_Note F2_500ms = { .note = F2, .duration_ms = 500 };
song_note.h
#include "note.h"
struct Song_Note {
struct Note note;
uint16_t duration_ms;
} Song_Note;
octave_two_notes.h
extern struct Note F2;
octave_two_notes.c
#define CALC_CTC_FREQ(clock_freq, prescaler, note_freq_hz) ( (uint32_t) clock_freq / ( (uint16_t) note_freq_hz * (uint16_t) prescaler * 2) - 1)
struct Note F2 = {.freq_hz = 87, .ocr_val = CALC_CTC_FREQ(16000000, 8, 87)};
note.h
#include <stdint.h>
struct Note {
uint16_t freq_hz;
uint16_t ocr_val;
} Note;