Conditional compilation?

28 views
Skip to first unread message

Paul Butcher

unread,
Oct 20, 2011, 6:53:15 PM10/20/11
to simple-b...@googlegroups.com
I'm cross-compiling my project for several different Scala versions. I have one isolated section of code that fails to compile under 2.9.1 because of a compiler bug. Is there any way to exclude a section of code when compiling with a specific compiler version?

@elidable won't work, because the code still has to compile :-(

The best that I can come up with is to move the code into a separate directory, which I add to unmanagedSources for all Scala versions apart from 2.9.1. Eugh. Any better suggestions?

There are times when I really miss the C pre-processor...

--
paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: pa...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher

Mark Harrah

unread,
Oct 23, 2011, 12:35:23 PM10/23/11
to simple-b...@googlegroups.com
On Thu, 20 Oct 2011 23:53:15 +0100
Paul Butcher <pa...@paulbutcher.com> wrote:

> I'm cross-compiling my project for several different Scala versions. I have one isolated section of code that fails to compile under 2.9.1 because of a compiler bug. Is there any way to exclude a section of code when compiling with a specific compiler version?
>
> @elidable won't work, because the code still has to compile :-(
>
> The best that I can come up with is to move the code into a separate directory, which I add to unmanagedSources for all Scala versions apart from 2.9.1. Eugh. Any better suggestions?

This isn't too bad, really. There are two alternatives that I can think of. First, you could modify the code to work under all compiler versions. I assume you've tried this, though.

Second, you could use a preprocessor. The error messages aren't as good because it isn't integrated with the compiler, though. See the sbinary build for one way of doing this using fmpp.

https://github.com/harrah/sbinary/blob/master/project/SBinaryProject.scala

-Mark

Paul Butcher

unread,
Oct 23, 2011, 5:57:15 PM10/23/11
to simple-b...@googlegroups.com
On 23 Oct 2011, at 17:35, Mark Harrah wrote:
> Second, you could use a preprocessor. The error messages aren't as good because it isn't integrated with the compiler, though. See the sbinary build for one way of doing this using fmpp.


Thanks, Mark - I'll check that out.

Reply all
Reply to author
Forward
0 new messages