www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - version dependence check

reply Shawn Liu <Shawn_member pathlink.com> writes:
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
Aug 08 2005
parent reply Shawn Liu <Shawn_member pathlink.com> writes:
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"?
Aug 08 2005
parent reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
"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.
Aug 08 2005
parent reply "Shawn Liu" <liuxuhong.cn gmail.com> writes:
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.
Aug 08 2005
parent Derek Parnell <derek psych.ward> writes:
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
Aug 08 2005