Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-09

FPC happily eats wrong parameters

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

Hi,

When calling "fpc -d foo test.pas" there are two mistakes: First the -d parameter is missing a value, which fpc silently ignores. And second there are two files to compile. FPC ignores that too, gives a hint, but compiles anyway.

Design or bug?

Mattias

Jonas Maebe
to Mattias Gaertner
Mattias Gaertner wrote 6 lines
When calling "fpc -d foo test.pas" there are two mistakes: First the -d parameter is missing a value, which fpc silently ignores. And second there are two files to compile. FPC ignores that too, gives a hint, but compiles anyway. Design or bug?

By design, FPC gives a warning (not a hint) when two file names are specified. Accepting an empty -d parameter sounds like a bug though.

Jonas

Sven Barth
to Mattias Gaertner: When calling "fpc -d foo test.pas" there are two mistakes: First the -d parameter is…
Mattias Gaertner wrote 8 lines
Hi, When calling "fpc -d foo test.pas" there are two mistakes: First the -d parameter is missing a value, which fpc silently ignores. And second there are two files to compile. FPC ignores that too, gives a hint, but compiles anyway. Design or bug?

The '-d' argument is written explicitely to do something only if it has a (directly following) argument. Otherwise it does nothing. If this should be considered a bug or not is up to discussion, but the code is this way at least since the migration to SVN.
That FPC warns if multiple files are supplied is by design as there is a specific warning about this. FPC will always use the last filename given as mentioned here:
http://www.freepascal.org/docs-html/user/userse70.html#x182-189000C.11

Regards,
Sven

Mattias Gaertner
to Jonas Maebe: By design, FPC gives a warning (not a hint) when two file names are specified. Accepting…
Show quoted text 12 lines
On 24 Sep 2013, at 14:17, Mattias Gaertner wrote: > When calling "fpc -d foo test.pas" there are two mistakes: > First the -d parameter is missing a value, which fpc silently ignores. > And second there are two files to compile. FPC ignores that too, gives > a hint, but compiles anyway. > > Design or bug? By design, FPC gives a warning (not a hint) when two file names are specified.

You are right, it is a warning.
Why not an error? In what case do you need to pass two files to the compiler?

Accepting an empty -d parameter sounds like a bug though.

ok

Mattias

Jonas Maebe
to Mattias Gaertner
Mattias Gaertner wrote 8 lines
On Tue, 24 Sep 2013 14:23:52 +0200 Jonas Maebe wrote: > By design, FPC gives a warning (not a hint) when two file names are > specified. You are right, it is a warning. Why not an error?

FPC used to silently ignore multiple file names, so I added a warning to remain backward compatible but make debugging such issues easier.

Jonas

Mattias Gaertner
to Sven Barth: The '-d' argument is written explicitely to do something only if it has a (directly…
Show quoted text 13 lines
Am 24.09.2013 14:17, schrieb Mattias Gaertner: > Hi, > > When calling "fpc -d foo test.pas" there are two mistakes: > First the -d parameter is missing a value, which fpc silently ignores. > And second there are two files to compile. FPC ignores that too, gives > a hint, but compiles anyway. > > Design or bug? The '-d' argument is written explicitely to do something only if it has a (directly following) argument. Otherwise it does nothing. If this should be considered a bug or not is up to discussion, but the code is this way at least since the migration to SVN.

Well, maybe the word "bug" is too strong.
It would be a nice feature, if fpc does not let the user shoot his foot this way.

That FPC warns if multiple files are supplied is by design as there is a specific warning about this. FPC will always use the last filename given as mentioned here: http://www.freepascal.org/docs-html/user/userse70.html#x182-189000C.11

Yes, it is this way since at least 2000. I assumed that eventually fpc will support compiling multiple files. But I guess this will not happen, so maybe it would be better to change the warning to an error. A warning is defined as something that is probably wrong, but may be needed in some cases. Where is the need for passing files that the compiler ignores?

Mattias