[sdiy] OT (but very synthy): C question

Olivier Gillet ol.gillet at gmail.com
Tue Mar 29 16:25:30 CEST 2011


Sorry for the mistake in my first post: forward declarations are C++ only.

The right syntax for forward struct declarations in C is:

typedef struct LFO LFO;
typedef struct MIDI MIDI;

I tried this fragment:

#include <stdio.h>

typedef struct LFO LFO;
typedef struct MIDI MIDI;

void update_midi(MIDI* midi, LFO* lfo);
void update_lfo(MIDI* midi, LFO* lfo);

struct MIDI {
  char running_status;
  char data[4];
};

struct LFO {
  int phase;
};

int main(int argc, char** argv) {
  printf("Hello, world!\n");
  return 0;
}


And it compiles.



More information about the Synth-diy mailing list