Pragmatic directives: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
No edit summary |
||
Line 196: | Line 196: | ||
Above would check for the COCOA feature and if not present, load the library. The library is also expected to later push the feature COCOA to the features list. Reading this code then later would ignore the require statement. |
Above would check for the COCOA feature and if not present, load the library. The library is also expected to later push the feature COCOA to the features list. Reading this code then later would ignore the require statement. |
||
=={{header|Delphi}}== |
|||
{{works with|Delphi|6.0}} |
|||
{{libheader|}} |
|||
Delphi has dozens of directive that change the way the compiler and the language work. |
|||
Here is a link describing the way directive work in general: |
|||
[https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Delphi_compiler_directives Using Delphi Directives] |
|||
Here is a list of all the directive available in current versions of Delphi: |
|||
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Delphi_Compiler_Directives_(List)_Index |
|||
<syntaxhighlight lang="Delphi"> |
|||
// Some examples |
|||
{$R *.dfm} |
|||
{$R WorldMaps.res} |
|||
{$optimization on,hints off} |
|||
{$B+} |
|||
{$R- Turn off range checking} |
|||
{$I TYPES.INC} |
|||
{$M 32768,40960} |
|||
{$DEFINE Debug} |
|||
{$IFDEF Debug} |
|||
{$ENDIF} |
|||
procedure DivMod(Dividend: Cardinal; Divisor: Word; |
|||
var Result, Remainder: Word); |
|||
{$IFDEF PUREPASCAL} |
|||
begin |
|||
Result := Dividend div Divisor; |
|||
Remainder := Dividend mod Divisor; |
|||
end; |
|||
{$ELSE !PUREPASCAL} |
|||
{$IFDEF X86ASM} |
|||
asm // StackAlignSafe |
|||
PUSH EBX |
|||
MOV EBX,EDX |
|||
MOV EDX,EAX |
|||
SHR EDX,16 |
|||
DIV BX |
|||
MOV EBX,Remainder |
|||
MOV [ECX],AX |
|||
MOV [EBX],DX |
|||
POP EBX |
|||
end; |
|||
{$ENDIF X86ASM} |
|||
{$ENDIF !PUREPASCAL} |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
</pre> |
|||
=={{header|D}}== |
=={{header|D}}== |