配置含有预处理功能的J2ME开发环境
======================================
使用方法:
在WTK下建立工程,
将含有预处理指令的代码放到和src同目录的srcp文件夹中
使用EditPlus或UE里边的自定义命令调用预处理程序cpp32
使用WTK编译
======================================
环境的组成:
WTK22
EditPlus2 或者 UltraEdit32
cpp32.exe
cpp32.vbs(封装cpp32.exe的脚本)
======================================
配置方法:
1. 将cpp32.exe 和 cpp32.vbs 拷贝到同一目录下面,我把他们拷贝到了EditPlus2的目录下,(/EditPlus 2/cusTools/中),毕竟他们要作为用户工具集成到EditPlus中。
2. 将cpp32.vbs集成到EditPlus2中。使用 [工具 -> 配置用户工具] 命令添加用户自定义工具,取个名字(例如"preprocess"),执行文件设置成脚本(/EditPlus 2/cusTools/cpp32.vbs),参数设置成 $(FilePath)。
3. 然后在编辑完你的java文件后,使用 preprocess 命令就行了,有快捷键使用的,很方便,^_^。
======================================
CPP32工具的使用说明
一般用法:
cpp32.exe -o输出文件 输入文件
使用上述命令产生解释预处理命令后的源代码文件。
程序说明:
Borland C++ Win32 Preprocessor 5.5.1 Copyright (c) 1993, 2000 Borland
Syntax is: CPP32 [ options ] file[s] * = default; -x- = turn switch x off
-Ax Disable extensions -C Allow nested comments
-Dxxx Define macro -Ixxx Include files directory
-P * Include source line info -Sc Keep comments
-Sd Defines/undefs in output -Sg Display fast guard details
-Sk Keep output on errors -Sr Readable commented output
-Ss Give header statistics -Uxxx Undefine macro
-gnnn Stop after N warnings -idl Accept some IDL syntax
-innn Max. identifier length N -jnnn Stop after N errors
-nxxx Output file directory -oxxx Output file name
-p Pascal calls -w Enable all warnings
-wxxx Enable warning xxx -w-xxx Disable warning xxx
=======================================
预处理命令
#define #undef
#include
#ifdef/#ifndef 标识符
程序段1
#else
程序段2
#endif
#if 常量表达式
程序段1
#else
程序段2
#endif
=======================================
脚本内容附在下面:
'
' CPP32.VBS
' Yi.Wang.
'
' 用于EditPlus/UltraEdit中用户工具。
' 将当前未预处理的java文件,使用CPP32处理后,放入工程的src/的目录下。
'
' 注意:
' ## 将cpp32.exe 和该脚本拷贝的同一个目录下面,最好时EditPlus目录。
' ## 该工具针对J2ME的WTK工程,所以保证有如下的目录结构:
' ------ src 存放预处理后的代码目录,也是WTK编译目录
' ------ srcp 当前代码目录
' |-- 当前代码文件(java)
'---------------------------------------------------------------
If WScript.Arguments.count <= 0 Then
WScript.Quit
End If
' SHELL
Set wshshell = CreateObject( "WScript.Shell" )
' File System Interface
Set fs = CreateObject( "Scripting.FileSystemObject" )
' non-preprocessed source file
infileName = WScript.Arguments(0)
If LCase( fs.GetExtensionName(infileName) ) <> "java" Then
MsgBox "Only accept *.java!",vbCritical
WScript.Quit
End If
' outputfile
outfileName = fs.GetParentFolderName( fs.GetParentFolderName( infileName ) ) & "/src/" & fs.GetFileName( infileName )
' execute cpp32.exe -ooutfileName -infileName
'MsgBox """" & fs.GetParentFolderName(WScript.scriptFullName) & "/cpp32.exe"" -o" & outfileName & " " & infileName
wshshell.run "cmd /K """"" & fs.GetParentFolderName(WScript.scriptFullName) & "/cpp32.exe"" -o""" & outfileName & """ """ & infileName & """ && pause && exit"""