如果在两种情况下都要,何必放在$ifdef $end中间呢?
解决方案 »
- 关于SQL SERVER中日期变量的问题
- 请问我该怎样才能控制对文件的读写权限???
- 一直郁闷我的问题,高手帮忙看看~~~~
- TADOtable怎么实现模糊查询(散分啦)
- 一个程序当我不关闭主程序的时候,第二次运行一个搜索窗口,就报错了。为什么?
- 请高手帮忙,dbgrid问题!!!!
- 气死我了,大家一起看看M$和Borland
- 当连接数据库时,如何去掉Microsoft access drivers[odbc]的密码提示,我不需要密码:(
- 如何设置打印机?
- 天啊!为什么在DBGRID中增加新记录出错?
- 即答即得之:有谁知道如何把query中的字段的DisplayName灌到checklistbox中去?我试了试,不能换行,是什么原因?
- 关于Database Desktop
{$define _BIG5}
{$endif}
尽量不要使用$IFDEF $IFNDEF......Using $IFDEF compiler directives is a reasonable way to conditionalize your code for the Windows and Linux platforms. However, because $IFDEFs make source code harder to understand and maintain, you need to understand when it is reasonable to use $IFDEFs. When considering the use of $IFDEFs, the top questions should be 揥hy does this code require an $IFDEF??and 揅an this be written without an $IFDEF??
Follow these guidelines for using $IFDEFs within cross-platform applications:Try not to use $IFDEFs unless absolutely necessary. $IFDEFs in a source file are only evaluated when source code is compiled. Unlike C/C++, Delphi does not require unit sources (header files) to compile a project. Full rebuilds of all source code is an uncommon event for most Delphi projects.
Do not use $IFDEFs in package (.dpk) files. Limit their use to source files. Component writers need to create two design-time packages when doing cross-platform development, not one package using $IFDEFs.In general, use $IFDEF MSWINDOWS to test for any Windows platform including WIN32. Reserve the use of $IFDEF WIN32 for distinguishing between specific Windows platforms, such as 32-bit versus 64-bit Windows. Don抰 limit your code to WIN32 unless you know for sure that it will not work in WIN64.
Avoid negative tests like $IFNDEF unless absolutely required. $IFNDEF LINUX is not equivalent to $IFDEF MSWINDOWS.Avoid $IFNDEF/$ELSE combinations. Use a positive test instead ($IFDEF) for better readability.
Avoid $ELSE clauses on platform-sensitive $IFDEFs. Use separate $IFDEF blocks for LINUX- and MSWINDOWS-specific code instead of $IFDEF LINUX/$ELSE or $IFDEF MSWINDOWS/$ELSE. For example, old code may contain{$IFDEF WIN32} (32-bit Windows code)
{$ELSE}
(16-bit Windows code) //!! By mistake, Linux could fall into this code.
{$ENDIF}For any non-portable code in $IFDEFs, it is better for the source code to fail to compile than to have the platform fall into an $ELSE clause and fail mysteriously at runtime. Compile failures are easier to find than runtime failures.Use the $IF syntax for complicated tests. Replace nested $IFDEFs with a boolean expression in an $IF directive. You should terminate the $IF directive using $IFEND, not $ENDIF. This allows you to place $IF expressions within $IFDEFs to hide the new $IF syntax from previous compilers. For recommendations concerning ending these directives, see Terminating conditional directives. For an overview of using conditional directives, see Conditional compilation.
如果是這樣呢?
{$define _ENG}
{$define _BG}
{$define _BIG5}To victorchen_2000(微力):
是否可以解釋一下!
{$define _BIG5} // 定义
{$endif}{$define _ENG}
{$define _BG}
{$define _BIG5}
这样定义了 _ENG _BG _BIG5 如果功能相同为什么要定义这么多?
可以只定义其中一个。