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

Tim Daugard daugard at cox.net
Mon Mar 28 18:50:38 CEST 2011


> Currently I have the LFO structure defined in LFO.h and the MIDIHandler 
> structure defined in MIDI.h. But I can't include MIDI.h in LFO.h *and* 
> also include LFO.h in MIDI.h.
> Where should I put things to avoid this problem?

Use inclusion guards
In one file (MIDI.h)
 #ifndef MIDI_H
  #define MIDI_H
   #ifndef LFO_H
   #inclde "LFO.h"
   #endif
...
#endif

in the other file (LFO.h)
 #ifndef LFO_H
  #define LFO_H
   #ifndef MIDI_H
   #inclde "MIDI.h"
   #endif
...
 #endif

Then it doesn't matter which is processed first


Tim Daugard
AG4GZ 30.4078N 86.6227W Alt: 12 feet above MSL
http://members.cox.net/synthfred/h_toctop.htm (Fred's online edition)





More information about the Synth-diy mailing list