Declaring a public constant as the same name as an internal symbol causes silent error
Original Reporter info from Mantis: CuriousKit @CuriousKit
-
Reporter name: J. Gareth Moreton
Original Reporter info from Mantis: CuriousKit @CuriousKit
- Reporter name: J. Gareth Moreton
Description:
Sorry for the long-winded name, but if you declare a constant with public visibility (either via using the "public" keyword or by declaring it in the "interface" section of a unit) and its name clashes with an internal symbol, the linker returns a silent error under Lazarus. All you see is "Fatal: Compilation aborted".
Now of course, this set-up is very contrived, especially as internal symbols start with "fpc_", but I needed to redeclare FPC_ABSMASK_DOUBLE as part of a test program, since I am unable to access internal functions and constants directly (feature request?).
Steps to reproduce:
Attempt to compile the attached source file and observe the error, or attempt to reproduce with another internally-defined constant or procedure (e.g. fpc_int_real).
Additional information:
Under Lazarus, there is no indication as to what the error is, which might confuse end users. When compiled from the command prompt, the error is clearer.
Free Pascal Compiler version 3.0.4 [2017/12/03] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling clash.pp
Linking clash.exe
clash.pp(8,1) Error: Multiple defined symbol FPC_ABSMASK_DOUBLE
clash.pp(8,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: C:\lazarus64\fpc\3.0.4\bin\x86_64-win64\ppcx64.exe returned an error exitcode
The error disappears if the "public" modifier is removed.
Mantis conversion info:
- Mantis ID: 34996
- OS: Microsoft Windows
- OS Build: 10 Professional
- Build: x86_64-win64
- Platform: x86_64-win64
- Version: 3.0.4
- Fixed in version: 3.3.1
- Fixed in revision: 1558 (#dfeeaca7)
- Target version: 3.2.0