[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to include a file just once?
From: |
Michael J. O'Donnell |
Subject: |
How to include a file just once? |
Date: |
Thu, 21 Jan 2010 11:47:08 -0600 |
User-agent: |
Thunderbird 2.0.0.23 (X11/20090817) |
Is there a standard way to make sure that a file full of LilyPond style
definitions is included just once, no matter how many times it is mentioned?
I searched the Web site, mail archives, and /usr/shar/lilypond for
"include once" and "include guard", to no avail. With the C
preprocessor, there is a standard trick for setting and testing a
variable to disable all but the first attempt to include a header file.
Some languages have an "include-once" command.
I am putting together a large choral score from bookparts for each
number in the work. I like to be able to produce either a single number,
or the whole score. The natural approach is to include style definitions
in each of the files that I might set, including the file to format the
whole score and the files to format individual numbers. Files to format
individual numbers also include the style definitions.
I find that repeated inclusion of the same definitions leads quickly to
a segmentation fault.
I can either add one more level of indirection, with one more file per
number. Or, I can do some Scheme hacking, with a global variable to set
showing inclusion (tricky, because the variable needs to be testable
reliably even when it has never been set explicitly).
But, I'd prefer to use a well-known standard method, if it exists.
Thanks,
Mike O'Donnell