Csound Csound-dev Csound-tekno Search About

expanding includes

Date2006-03-23 22:28
FromAtte André Jensen
Subjectexpanding includes
Hi

I have an score and an orchestra with lots of includes, several levels 
deep. Is there a way to expand the score/orchestra and get two 
self-contained files?

-- 
peace, love & harmony
Atte

http://www.atte.dk

Date2006-03-24 04:59
FromAnthony Kozar
SubjectRe: expanding includes
Well, since the syntax for including files is the same in Csound as it is in
C (at least if you use ""), then I would think that you could use the C
Preprocessor to do the job.  I am not sure what the options to gcc would be
for just preprocesing a file, but you could probably find out with a "man
gcc".

Note, though, that if you also have macros in your files (or the new #ifdef)
that these will likely cause the C preprocessor to report errors or to
perform text substitutions that you do not want it to.

Anthony Kozar
anthonykozar AT sbcglobal DOT net


Atte André Jensen wrote on 3/23/06 5:28 PM:

> I have an score and an orchestra with lots of includes, several levels
> deep. Is there a way to expand the score/orchestra and get two
> self-contained files?

Date2006-03-24 09:20
FromAtte André Jensen
SubjectRe: expanding includes
Anthony Kozar wrote:

> Note, though, that if you also have macros in your files (or the new #ifdef)
> that these will likely cause the C preprocessor to report errors or to
> perform text substitutions that you do not want it to.

I have loads of macros, so...

Any other ideas?

-- 
peace, love & harmony
Atte

http://www.atte.dk

Date2006-03-24 18:21
FromAnthony Kozar
SubjectRe: expanding includes
AttachmentsCsInclExp.cpp  
Attached is a simple C++ program that reads in a CSD, Orc, or Sco file and
recursively expands its includes.  Currently, your files must all be in the
same directory or your #includes should use appropriate relative and/or full
pathnames.

Output is sent to standard out, so use it like this:

     programname  [inputfile] > outputfile


It seems to work reasonably well for me, but it is probably not perfect.
(For one thing, it does not emulate Csound's (faulty) include behavior where
linefeeds are not added to the end of an included file if not present).

If anyone makes improvements to this program, I would appreciate receiving a
copy of your code.  (One good feature to add would be the ability to set
include directories from the commandline).

Anthony Kozar
anthonykozar AT sbcglobal DOT net


Atte André Jensen wrote on 3/24/06 4:20 AM:

> Anthony Kozar wrote:
> 
>> Note, though, that if you also have macros in your files (or the new #ifdef)
>> that these will likely cause the C preprocessor to report errors or to
>> perform text substitutions that you do not want it to.
> 
> I have loads of macros, so...
> 
> Any other ideas?