[Lazarus] semaphore
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Fri Feb 17 12:13:33 CET 2012
Mattias Gaertner schrieb:
>>>> trying to generate the procedure event code, the unit "ipc" is open and
>>>> the error "/usr/share/fpcsrc/rtl/unix/ipc.pp(119,9) Error: expected
>>>> end., but seq found" is displayed in the errors window
This error message looks correct.
>>>> {$if sizeof(kernel_mode_t)< 4}
>>>> [114] __pad1 : array[1..4-sizeof(mode_t)];
This syntax either is illegal or should be added to the parser.
>>> svn trunk can now parse it.
>> I somehow doubt this. It seems more like the condition there is never
>> true and thus the omition was never noticed.
Right, it looks like a lurking bug to me.
Once the source code is fixed, what doesn't look complicated to me, and
doesn't break anything, the problem has gone away. A dedicated "align"
directive instead of the explicit alignment had been helpful, too.
The parser also may treat the "of <type>" as optional. This also doesn't
look hard to implement, and may be useful in other situations (while
source code is edited).
> At least according to the
>> compiler's code there MUST be a "of" after an array. So it might have
>> been better to investigate why "sizeof(kernel_mode_t) < 4" is evaluated
>> to true by the IDE.
>
> kernel_mode_t is defined in another unit.
> The size_of requires parsing like a compiler, that means reading all
> ppu files first and resolving every type on its way. And it requires
> implementation details of the compiler.
> I guess only the compiler can reliably resolve size_of.
+1
Conditional compilation either requires the *correct* settings, required
to evaluate every condition, or silent handling of problems resulting
from inproperly included/excluded parts.
> Same for declared.
>
> Maybe some heuristics and/or defines can be added to help codetools
> parsing such $IFs.
This IMO would open up a can of worms. Adding the full compiler
capabilites to general parsers, including e.g. machine and OS targets,
is near impossible. The related compiler units are not usable outside
the compiler, and every attempt to create parallel units will end up in
a maintenance nightmare. Also much time will be spent, and memory will
be occupied, when all used units have to be parsed before the currently
active unit.
In the ToPas C-to-Pascal converter I had not only to parse all include
files for an specific compiler, but also all effective compiler defines
(built-in or configurable) had to be known. This made the proper
configuration for a translation very complicated, and the tool unusable
for people not very familiar with a specific compiler.
DoDi
More information about the Lazarus
mailing list