Description: #if fred Is treated as a comment. It should always be treated as an error. Steps to Reproduce: Create new Basic subroutine: sub Mysub #if fred dim a as int #else dim a as int #endif end sub Run the sub. 1.Import VBA module containing #if, #else, #endif 2.Run any function in the module 3. Actual Results: BASIC syntax error. Variable a already defined. Expected Results: Lines starting with # are errors Reproducible: Always User Profile Reset: Yes Additional Info: It would be really nice if BASIC handled #if, #else the same way VBA 6 or 7 do: as conditional compilation meta commands. Some older OO versions handled this differently, the initial syntax check handled #if as if: for declaration outside of a function I got "If outside of function or sub is not allowed" But the present implementation is even worse: #if and #else are silently ignored when inside a function, so both branches are included. In VBA back to Office 97, #if allows you to include different branches for different #defines. There are predefined values ('Win32' etc), and two different ways of defining values. #if is commonly used to allow different branches for VBA7 and OSX: it may also be used generally, as for debug builds. When VBA code is imported into LO, the idiosyncratic treatment of # meta commands is confusing and unexpected: the lack of documentation contributes to the problem. Implementing the feature correctly would be good: implementing the feature in a minimal way with a clear error message would be good enough. Version: 7.4.2.3 (x86) / LibreOffice Community Build ID: 382eef1f22670f7f4118c8c2dd222ec7ad009daf CPU threads: 4; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win Locale: en-AU (en_AU); UI: en-US Calc: threaded
@Andreas, I thought you might be interested in this issue
Here's official VBA documentation on this matter https://learn.microsoft.com/en-us/office/vba/language/concepts/getting-started/compiler-constants