Thread overview
version dependence check
Aug 08, 2005
Shawn Liu
Aug 08, 2005
Shawn Liu
Aug 08, 2005
Ben Hinkle
Aug 08, 2005
Shawn Liu
Aug 08, 2005
Derek Parnell
August 08, 2005
see the code below:

// file: versionctrl.d
module versionctrl;
version(ANSI){
}else{
// want to use unicode as default
version = UNICODE;
}

// file: test.d
module test;

import versionctrl;

class Test{
version(ANSI){
void foo(){ printf("Ansi version\n");}
}
version(UNICODE){
void foo(){ printf("Unicode version\n");}
}
}

void main(){
Test t = new Test();
t.foo();
}

// compiled with no version set, Unicode desired dmd versionctrl.d test.d


test.d(16): no property 'foo' for type 'test.Test'
test.d(16): function expected before (), not 1 of type int


// it seems that DMD didn't check the version for // versionctrl.d though it is imported by test.d



August 08, 2005
In article <dd73ap$1t2f$1@digitaldaemon.com>, Shawn Liu says...
>
>see the code below:
>
>// file: versionctrl.d
>module versionctrl;
>version(ANSI){
>}else{
>// want to use unicode as default
>version = UNICODE;
>}
>

we can copy the content of "versionctrl.d" to the top of the "test.d" to solve
this.
but copy hundreds of this content in a big project is annoying.
Can we just import the "versionctrl"?



August 08, 2005
"Shawn Liu" <Shawn_member@pathlink.com> wrote in message news:dd74t8$1umg$1@digitaldaemon.com...
> In article <dd73ap$1t2f$1@digitaldaemon.com>, Shawn Liu says...
>>
>>see the code below:
>>
>>// file: versionctrl.d
>>module versionctrl;
>>version(ANSI){
>>}else{
>>// want to use unicode as default
>>version = UNICODE;
>>}
>>
>
> we can copy the content of "versionctrl.d" to the top of the "test.d" to
> solve
> this.
> but copy hundreds of this content in a big project is annoying.
> Can we just import the "versionctrl"?

Pass the version info to the compiler at the command-line. Version statements only affect the module in which they live.


August 08, 2005
see the example from D page, http://www.digitalmars.com/d/version.html#version


	version (ProfessionalEdition)
	{
	    version = FeatureA;
	    version = FeatureB;
	    version = FeatureC;
	}
	version (HomeEdition)
	{
	    version = FeatureA;
	}
	...
	version (FeatureB)
	{
	    ... implement Feature B ...
	}





Suppose we have several files (maybe hundreds of files) in a project, we
have to copy above code into EVERY file.
Otherwise the code inside version(FeatureB) will not be compiled.

Another way is passing "-version=FeatureB -version = FeatureC" to the
compiler as you said.
If so, the "version = ???" feature seems useless.


This is far different from C. If we define some thing in previous h file, the current file will inherit those feature when the previous file is included.



"Ben Hinkle" <ben.hinkle@gmail.com> wrote:dd7hlg$2an2$1@digitaldaemon.com...
>
> "Shawn Liu" <Shawn_member@pathlink.com> wrote in message news:dd74t8$1umg$1@digitaldaemon.com...
>> In article <dd73ap$1t2f$1@digitaldaemon.com>, Shawn Liu says...
>>>
>
> Pass the version info to the compiler at the command-line. Version statements only affect the module in which they live.
> 


August 08, 2005
On Tue, 9 Aug 2005 00:16:07 +0800, Shawn Liu wrote:

> see the example from D page, http://www.digitalmars.com/d/version.html#version
> 
> 
> 	version (ProfessionalEdition)
> 	{
> 	    version = FeatureA;
> 	    version = FeatureB;
> 	    version = FeatureC;
> 	}
> 	version (HomeEdition)
> 	{
> 	    version = FeatureA;
> 	}
> 	...
> 	version (FeatureB)
> 	{
> 	    ... implement Feature B ...
> 	}
> 
> 
> 
> 
> 
> Suppose we have several files (maybe hundreds of files) in a project, we
> have to copy above code into EVERY file.
> Otherwise the code inside version(FeatureB) will not be compiled.
> 
> Another way is passing "-version=FeatureB -version = FeatureC" to the
> compiler as you said.
> If so, the "version = ???" feature seems useless.
> 
> 
> This is far different from C. If we define some thing in previous h file, the current file will inherit those feature when the previous file is included.

Sounds like an enhancement I could make to Build...

  version(build) pragma(export_version, "FeatureB");

to place "-version=FeatureB" on the dmd command line automatically for you.

Something like that anyway. What do you guys think?

-- 
Derek Parnell
Melbourne, Australia
9/08/2005 2:27:04 AM