其中建设要考虑使用在使用preprocessor

其中建设要考虑使用在使用preprocessor

本文介绍了其中建设要考虑使用在使用preprocessor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有需要4.6和5.0版本的黑莓要使用的项目。
我已经在这两个4.6和5.0版本,连接到code一些preprocessor指令运行同一code(其中的#ifndef我需要使用5.0如Facebook SDK是不是4.6版本所支持的语句)
我有2 .cod文件(一个用于4.6和其他5.0)
他们的工作需要在其各自的模拟器。

I have a project which needs to be used in 4.6 and 5.0 versions of blackberry.I have run same code in both the 4.6 and 5.0 versions with some preprocessor directives attached to the code (#ifndef statements which i need to use for 5.0 as facebook sdk is not supported in 4.6 version)I have 2 .cod files ( one for 4.6 and other for 5.0)they work as needed in their respective simulators.

但是,当我的4.6 .cod文件加载到5.0 ......(它把它作为preprocessor作为注释里面的code)
当我做到这一点反之亦然

But, when i load the .cod file of 4.6 into 5.0 ... (it treats it as the code inside preprocessor as comment)and when i do it viceversa

即由5.0到4.6 ...它说......没有发现项目名称,1.cod。

ie from 5.0 into 4.6 ... it says ... projectname-1.cod not found .

有一个类似的问题在这里被张贴过检查,其中对bbtool评论说,这可能是可能的
One建立在黑莓(以上4.6,4.7和5.0 +)两个不同的版本。

A similar question is been posted here too check out where a comment on bbtool says it can be possibleOne build for two different versions (4.6,4.7 and 5.0+above) in blackberry

推荐答案

使用preprocessor是不是让的方式单一BUILD 针对不同的BB OS版本(不管你用什么工具来prepare的版本)。

Using preprocessor is not the way to make A SINGLE BUILD for different BB OS Versions (No matter what tool you use to prepare the build).

preprocessors都只是用来删除/添加基于编译/构建整个code之前提供的条件code的特定部分。
更一般地,preprocessors被用于不同的考虑源$ C ​​$ c代表不同的条件。
更更一般地,preprocessors用于产生不同的源$ C ​​$ CS为不同的条件。
在这种情况下preprocessors的范围仅之前编译/构建code ... 后没有您已经建立code和得到了可执行/ .COD / ...等。文件

Preprocessors are used just to remove/add particular portion of code based on provided conditions before compiling/building the entire code.More generally, preprocessors are used to consider the source code differently for different conditions.More more generally, preprocessors are used to produce different source codes for different conditions.In such a case the scope of preprocessors is only before compiling/building the code... not after you have build the code and got the executable/.cod/...etc. file

阅读的 的的 Ë链接;虽然这些是关于C- preprocessors,但基本也适用在这里。

Read first few lines of T H E S E links; though these are about C-Preprocessors, but the basic is also applicable here.

假设你的code是如下:

Suppose your code is as following:

// START OF CODE
//#preprocess
// this is the second line of the code
//...
//#ifdef OS_5
import net.rim.device.api.ui.component.AutoCompleteField;
//#else
//don't import AutoCompleteField and import something else if needed
//#endif

//...
//... // some more codes
//...

//#ifdef OS_5
//...
//...
// Codes for using AutoCompleteField
//...
//...
//#else
//...
//...
// Codes for implementing AutoCompleteField another way by yourself
//...
//...

//...
//... // some more codes
//...
 // END OF CODE

它不会不管你用什么工具来构建你的code(JDE,Eclipse或使用Ant),如果你建立的preprocessor ​​'OS_5 然后(如果你的工具可以理解preprocessors)以下的code会产生:

It doesn't matter what tool you use to build your code (JDE, Eclipse or using Ant), if you build with the preprocessor 'OS_5' then (if your tool can understand preprocessors) the following code will be generated :

// START OF CODE
// this is the second line of the code
//...
import net.rim.device.api.ui.component.AutoCompleteField;

//...
//... // some more codes
//...

//...
//...
// Codes for using AutoCompleteField
//...
//...

//...
//... // some more codes
//...
 // END OF CODE

.COD 文件将与上述code产生。而这个 .COD 文件不会对BB OS版本上运行低于5.0,因为 AutoCompleteField 从OS 5的支持。

and the .cod file will be generated with the above code. And this .cod file will not run on BB OS Versions less than 5.0 because AutoCompleteField is supported from OS 5.

如果你打造的没有的preprocessor ​​OS_5或其他preprocessors
那么下面code会产生:

And if you build without the preprocessor 'OS_5' or other preprocessorsthen the following code will be generated:

// START OF CODE
// this is the second line of the code
//...
//don't import AutoCompleteField and import something else if needed

//...
//... // some more codes
//...


//...
//...
// Codes for implementing AutoCompleteField another way by yourself
//...
//...

//...
//... // some more codes
//...
 // END OF CODE

和将使用上述code生成 .COD 文件,这将是一个不同的 .COD 文件超过previous之一。

and the .cod file will be generated using the above code, and This is going to be a different .cod file than the previous one.

现在,如果你想prepare 单一BUILD 并部署它成功地不同的BB OS支持的设备,那么你必须删除依赖性同时编码,即仅使用由所有操作系统版本(4.6,5.0 ......等等,如果你想)支持这些API的类。但它是非常困难的,有时某些情况下,因为你可能会写自己的codeS实现某些功能。

Now if you want to prepare A SINGLE BUILD and deploy it successfully different BB OS supported devices, then you have to remove dependencies while coding, i.e. use only those API-classes that are supported by all the OS versions (4.6, 5.0... and others if you want). But it's very difficult sometimes for some cases, because you may have to write your own codes for implementing some features.

它更容易prepare建立不同的不同的操作系统---和这个目的,你可以使用过程preprocessors的。

It's easier to prepare different builds for different OS --- and on that purpose you can of course use preprocessors..

恐怕可我有一个非常复杂的方式解释一件容易的事情。

I'm afraid may be I have explained an easy thing in a very complex way.

这篇关于其中建设要考虑使用在使用preprocessor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 16:08