Pre-Processing ActionScript files with cpp on OSX
Posted by Ali Mills Tue, 06 Jan 2009 22:08:00 GMT
Back in March 2005, Mike Chambers wrote a couple interesting posts about using cpp, a C pre-processor, to pre-process ActionScript files.
He noted that, while cpp is included on Mac OS X, for some reason it wasn’t working for him. Well, I think that I just found the reason. It appears that cpp’s docs and man pages don’t emphasize how picky the tool is about white space.
To get the examples to work on my MacBook, I had to make some minor white space modifications.
I had to get rid of all the white space before the #ifdef directive like so:
1 2 3 4 5 6 7 | |
And, I had to drop the space between the ā-Dā flag and the DEBUG macro name when calling cpp. The command ended up looking like this:
1 | |
That did it for me. With those changes and Mike’s introduction to pre-processing ActionScript files and classes, I have cpp working on OSX with ActionScript just fine.
WooHoo!













That's a great question!
We aren't actually doing any preprocessing on our projects right now, but we did just release a new build of Sprouts (http://projectsprouts.org) that supports it.
The big idea was that BrightRoll wants to use preprocessors to accomplish a variety of things.
Pull debug code from production builds, include auto-incremented revisions, toggle debug state, etc..
And they'll be using Sprouts to automate their build for development and with Cruise Control integration.
Thanks!