Repository navigation
Caller Line
Home › Intrinsic Defines › CALLER_LINE and CALLER_FILE
The line and file of the statement that calls a procedure, written as a parameter's default.
byval paramLine as long = __CALLER_LINE__
byval paramFile as zstring ptr = __CALLER_FILE__A parameter default is evaluated again at every call, at the call. __CALLER_LINE__ and __CALLER_FILE__ are the line number (long) and the source file's path as it was given to the compiler (zstring ptr) of the statement being compiled, so a default made of them is the caller's line and file. A procedure that reports a misuse, such as std/outcome's Value( ) on an empty Optional, can then name the line where the mistake was made rather than a line inside itself.
An argument written at the call replaces the default as usual.
Anywhere else they are the line and file of the statement they appear in, like __LINE__ and __FILE__. Unlike those two, they are not preprocessor macros: they are names the compiler fills in where it compiles the expression, so #print and #if do not see them.
A caller's location passes one level only. A procedure that wants its own caller's line to reach a procedure it calls passes it on explicitly.
They are tiko's own. __TIKO_CALLER_LOCATION__ is defined (as 1) by a compiler that has them, so a library can test for them with #ifdef.
sub Check( byval ok as boolean, byval ln as long = __CALLER_LINE__, byval fl as zstring ptr = __CALLER_FILE__ )
if ok = false then print "check failed at "; *fl; " line"; ln
end sub
Check( 1 = 1 )
Check( 1 = 2 ) '' check failed at demo.tiko line 6- Not in FreeBASIC.
__LINE__inside a default is the declaration's line, since the preprocessor replaces it there.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Match
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Array Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- tiko test
- tiko doc
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing