|
8 | 8 |
|
9 | 9 | { Test is based on testver.c } |
10 | 10 |
|
| 11 | +{$DEFINE C_VARIADIC_LOG} // !!! This define compiles Case 2. Comment out for Case 1 !!! |
| 12 | + |
11 | 13 | program testver; |
12 | 14 |
|
13 | 15 | uses |
14 | | - SDL3, SysUtils; |
| 16 | + SDL3 {$IFNDEF C_VARIADIC_LOG}, SysUtils{$ENDIF}; |
15 | 17 |
|
16 | 18 | var |
17 | 19 | version: Integer; |
|
22 | 24 | else |
23 | 25 | SDL_Log('Compiled with SDL older than 3.0'); |
24 | 26 |
|
| 27 | +{ Case 1: Do NOT use C's variadic function: |
| 28 | +
|
| 29 | + Uses SDL_Log(fmt: PAnsiChar) with only the string parameter. |
| 30 | + There is not variadic part in the SDL function itself. |
| 31 | +
|
| 32 | + The variadic part is provided by Pascal's Format() function |
| 33 | + from SysUtils. } |
| 34 | +{$IFNDEF C_VARIADIC_LOG} |
| 35 | + SDL_Log('Case 1: SDL_Log without variadic part.'); |
25 | 36 | SDL_Log(PChar(Format('Compiled version: %d.%d.%d (%s)',[ |
26 | 37 | SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION, |
27 | 38 | SDL_REVISION]))); |
28 | 39 | version := SDL_GetVersion(); |
29 | 40 | SDL_Log(PChar(Format('Runtime version: %d.%d.%d (%s)', |
30 | 41 | [SDL_VERSIONNUM_MAJOR(version), SDL_VERSIONNUM_MINOR(version), SDL_VERSIONNUM_MICRO(version), |
31 | 42 | SDL_GetRevision()]))); |
| 43 | + {$ENDIF} |
| 44 | + |
| 45 | +{ Case 2: Use C's variadic function: |
| 46 | +
|
| 47 | + Uses SDL_Log(fmt: PAnsiChar; Args: array of const). The variadic part |
| 48 | + is provided directly by C's function. SysUtils is not needed. } |
| 49 | +{$IFDEF C_VARIADIC_LOG} |
| 50 | + SDL_Log('Case 2: SDL_Log with variadic part.'); |
| 51 | + SDL_Log('Compiled version: %d.%d.%d (%s)', [ |
| 52 | + SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION, |
| 53 | + SDL_REVISION]); |
| 54 | + version := SDL_GetVersion(); |
| 55 | + SDL_Log('Runtime version: %d.%d.%d (%s)', |
| 56 | + [SDL_VERSIONNUM_MAJOR(version), SDL_VERSIONNUM_MINOR(version), SDL_VERSIONNUM_MICRO(version), |
| 57 | + SDL_GetRevision()]); |
| 58 | +{$ENDIF} |
| 59 | + |
32 | 60 | SDL_Quit(); |
33 | 61 | end. |
34 | 62 |
|
0 commit comments