Compiler Tokens
NBC supports special tokens, which it replaces on compilation. The tokens are similar to preprocessor #define macros but they are actually handled directly by the compiler rather than the preprocessor. The supported tokens are as follows:
Token | Usage |
---|---|
__FILE__ | This token is replaced with the currently active filename (no path) |
__LINE__ | This token is replaced with the current line number |
__VER__ | This token is replaced with the compiler version number |
__THREADNAME__ | This token is replaced with the current thread name |
__I__, __J__ | These tokens are replaced with the current value of I or J. They are both initialized to zero at the start of each thread or subroutine. |
__ResetI__, __ResetJ__ | These tokens are replaced with nothing. As a side effect the value of I or J is reset to zero. |
__IncI__, __IncJ__ | These tokens are replaced with nothing. As a side effect the value of I or J is incremented by one. |
__DecI__, __DecJ__ | These tokens are replaced with nothing. As a side effect the value of I or J is decremented by one. |
The ## preprocessor directive can help make the use of compiler tokens more readable. __THREADNAME__##_##__I__: would become something like main_1:. Without the ## directive it would much harder to read the mixture of compiler tokens and underscores.