- changed status to open
.inc file support
Hi,
Finding method fails when the method is in an include (.inc) file. And FPC has tons of include files.
Thank you.
~Bee
Comments (5)
-
repo owner -
reporter test.pas
main program:program test; uses CRT; var s: string; begin s := ask('Type your name: '); writeln('Hello, ',s); end.
unit1.pas
unit:unit unit1; interface function ask(q: string): string; implementation {$I unit1.inc} end.
OmniPascal gives warning: "implementation is missing for
ask
(5,1)".unit1.inc
include file:function ask(q: string): string; begin write(q); readln(Result); end;
OmniPascal gives error: "unit name must be
unit1
(1,6)".Of course FPC (v.3.0 64-bit on Mac) compiles program
test
just fine without any errors or warnings. -
repo owner Thanks for the files and sorry for the very late answer. I tested your code against the current master which will be the upcoming version of OmniPascal.
You show two errors here. The first one can't be reproduced with the current master. Since I've changed a lot of stuff regarding warnings and errors I assume I've fixed it by accident. I don't know how to handle the second error in a good way. When an
.inc
file is opened in an editor then OmniPascal has no information about the location(s) where it's included. So OmniPascal treats it like a a Pascal source file: And these files never start withfunction
. That's why the parser produces errors in these cases. This won't be fixed soon. -
Although it's not considered as a good practice, syntactically speaking, a Pascal program is allowed to be started with
function
orprocedure
keyword. For example, below code can be compiled just fine, at least using FPC.function f: string; begin result := 'function'; end; begin writeln(f); end.
Also the Pascal program name (after the
program
keyword) doesn't have to be exactly equal to the actual program file name. It's fine to have aprogram Fibonacci;
while the actual program file name isfibo.pas
. 😊 -
Hi, my inc file is like
{.$DEFINE NOSCRIPT}
{$IFDEF SUPERADMIN} {$IFDEF MSWINDOWS} {$DEFINE SM_DEBUG} {$ENDIF}
which is perfectly valid in both Delphi and FPC and have the same (1,6) error
- Log in to comment
Please provide more detailed information about the code you are working with. Include files are supported and do work fine in general. But OmniPascal can't parse all FPC related units since FPC has tons of different syntactic language constructs which are not worth to reimplement in OmniPascal by now. This can lead to missing items in code completion and incomplete go-to-definition-support for FPC base classes.
Delphi
is the only language mode OmniPascal attempts to support entirely.