Colons and brackets
Daniel Murphy
yebbliesnospam at gmail.com
Sun Mar 2 06:12:20 PST 2014
"evilrat" wrote in message news:mxhmgkljrzqhaymeclvk at forum.dlang.org...
On Friday, 28 February 2014 at 04:19:47 UTC, Etienne Cimon wrote:
> >
> > How do you stop statements from belonging to the specific version of
> > code without using brackets?
>
> add "version(all):" after code where specific version ends.
This is incorrect, there is no way to do this.
The compiler translates
version(...):
...
into
version(...)
{
...
}
So any version labels after the first are moved inside the first.
You can see it with this code:
version = y;
version(x):
pragma(msg, "versionx");
version(y):
pragma(msg, "versiony");
Nothing is printed, because the version(y) block is inside the version(x)
block, and version(x) is not set.
The answer: use braces.
More information about the Digitalmars-d-learn
mailing list