_OS$
Jump to navigation
Jump to search
The _OS$ function returns the operating system name and QB64(PE) compiler bit version used to compile a program.
Syntax
- osInfo$ = _OS$
Description
- Returns a STRING listing the OS as [WINDOWS], [LINUX] or [MACOSX] and the compiler bit format of [32BIT] or [64BIT].
- Additionally the [ARM] identifier is set, if QB64-PE was used on Windows, Linux or macOS on an ARM processor such as Apple M series or Qualcomm Snapdragon X series SoCs. (see Availability)
- Allows a program compiled with QB64(PE) in Windows, Linux or macOS to determine and use different OS or language specific code, e.g. when SHELL is used with dir vs. ls depending on the OS.
- It's recommended to use INSTR for matching single tags in the osInfo$ string.
- Important Note
- Even if you're on a 64-bit Windows system, the _OS$ function may return [32BIT].
- That is, if your program was compiled with the 32-bit version of QB64(PE), hence it's a 32-bit executable running on 64-bit Windows.
- This is by design and not a bug, as your program gets the information it needs to run (e.g. to use 32-bit or 64-bit DLLs using DECLARE DYNAMIC LIBRARY) and not what you as user would expect to see according to your system.
- That's why the "used to compile" phrase was printed bold in the first line above.
Availability
-
v0.926
-
all
-
yes
-
yes
-
yes
- In QB64-PE v4.2.0 the new [ARM] identifier was introduced and is set when applicable.
Examples
- Showcasing all general compiler information functions.
'Getting info where and when a program was compiled. PRINT: PRINT " This program was compiled on "; COLOR 15: PRINT _COMPILEDATE$; COLOR 7: PRINT " at "; COLOR 15: PRINT _COMPILETIME$; COLOR 7: PRINT " by " COLOR 7: PRINT " using "; COLOR 15: PRINT _COMPILERVERSION$; " "; _OS$; COLOR 7: PRINT "." END |
- This is how the output could look like, the exact data actually depends on the circumstances during the compile operation.
This program was compiled on Mar 6 2026 at 19:43:21 by using QB64-PE v4.4.0 [WINDOWS][64BIT]. |
See also