Sign in Join

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

Mailing lists / lazarus / 2011-07

-WG compiler parameter issue in cross-platform projects

13 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Hi,

Last night I switched to FPC 2.5.1 and tried to compile my project. I got a compiler error because I had the "Windows GUI application" (-WG compiler parameter) checked in my project setting.

Lazarus being cross-platform and all, how am I supposed to handle this issue in a Lazarus project? Now (currently) I can't simply open the project under Linux and compile - I have to first untick the compiler option. But I can simply compiler under Windows - but I must remember to have that option ticked.

Any ideas on how to handle this FPC (platform specific) change gracefully in Lazarus projects?

Note:
In older versions of FPC (like 2.4.4) the -WG parameter was simply ignored under any platform other than Windows. In Trunk it now gives a compiler error! :-(

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Graeme Geldenhuys
to Graeme Geldenhuys

Searching the mailing list archives (which I should have done before I posted - sorry), I noticed that there was recently a discussion about this issue, but from that message thread I couldn't determine what the final solution was.

BTW:
I am using the latest stable Lazarus IDE 0.9.30. So from a earlier message thread, it seems we can't use stable Lazarus IDE with FPC Trunk any more. Was a solution found for latest Lazarus IDE in Trunk branch?

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Felipe Monteiro de Carvalho
to Graeme Geldenhuys
Graeme Geldenhuys wrote
BTW: I am using the latest stable Lazarus IDE 0.9.30. So from a earlier message thread, it seems we can't use stable Lazarus IDE with FPC Trunk any more.

One solution is creating a windows-only build mode, but I don't remember if 0.9.30 has build modes, since I always use trunk...

Was a solution found for latest Lazarus IDE in Trunk branch?

Yes, the IDE will only add this option for windows targets.

Although I still think this is a bug in FPC.

Felipe Monteiro de Carvalho

Reply by email

Graeme Geldenhuys
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
One solution is creating a windows-only build mode, but I don't remember if 0.9.30 has build modes, since I always use trunk...

My version (0.9.30.1) does have a option for build modes, but the -WG fall under the "Linking" settings. I'll have to figure out how build modes work in Lazarus first.

> Was a solution found for latest Lazarus IDE in Trunk branch? Yes, the IDE will only add this option for windows targets.

OK, I'll update my Lazarus then, because currently it doesn't do that in 0.9.30.x

Although I still think this is a bug in FPC.

+1 What is the point of 'cross-platform support' then? Letting the compiler simply ignore parameters that ain't relevant for the target seems a rather simple solution - at it worked like that for years. Except now.

Thanks for the info Felipe.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Sven Barth
to Graeme Geldenhuys
Graeme Geldenhuys wrote 6 lines
> Although I still think this is a bug in FPC. +1 What is the point of 'cross-platform support' then? Letting the compiler simply ignore parameters that ain't relevant for the target seems a rather simple solution - at it worked like that for years. Except now.

I'm quoting Florian's answer from the before mentioned thread "Illegal paramater: -WG" from around 7th June this year:

=== quote begin ===

Maybe it's worse to check all the -W switches in lazarus. I made them all target dependent.

=== quote end ===

So it seems that it was a concsious decision by Florian. For the "why" you need to ask him though ^^

Regards,
Sven

Reply by email

Florian Klämpfl
to Sven Barth
Sven Barth wrote 20 lines
Am 14.07.2011 11:43, schrieb Graeme Geldenhuys: >> Although I still think this is a bug in FPC. > > +1 What is the point of 'cross-platform support' then? Letting the > compiler simply ignore parameters that ain't relevant for the target > seems a rather simple solution - at it worked like that for years. > Except now. I'm quoting Florian's answer from the before mentioned thread "Illegal paramater: -WG" from around 7th June this year: === quote begin === Maybe it's worse to check all the -W switches in lazarus. I made them all target dependent. === quote end === So it seems that it was a concsious decision by Florian. For the "why" you need to ask him though ^^

Pretty simple: most target specific switches were never silently ignored if they didn't apply to the current target. A arm compiler complains also about a -Oppentium. -WG was one of the few examples of the group of the -W switches which was silently ignored, probably due to historic reasons.

Further, fpc is a pascal compiler, it tries to prevent people to shoot themself into the foot. And to ignore silently command line switches if they don't apply is imo very bad practive. Last but not least, fpc provides enough means to do this properly by using ifdef in configuration files or using the apptype directive. And I'am pretty sure, lazarus will offer a good solution as well to do this properly.

Reply by email

Felipe Monteiro de Carvalho
to Florian Klämpfl
Florian Kl?mpfl wrote 5 lines
Pretty simple: most target specific switches were never silently ignored if they didn't apply to the current target. A arm compiler complains also about a -Oppentium. -WG was one of the few examples of the group of the -W switches which was silently ignored, probably due to historic reasons.

I think that the major problem will be trying to create a cross-platform makefile for fpc apps. I for one can create simple makefiles, but I have no idea how to add if clauses in makefiles to select the correct options for each platform.

Plus, while most options are optional, -WG is pretty much mandatory in Windows GUI apps, so you can't just live without it.

Felipe Monteiro de Carvalho

Reply by email

Florian Klämpfl
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 11 lines
On Thu, Jul 14, 2011 at 7:07 PM, Florian Kl?mpfl wrote: > Pretty simple: most target specific switches were never silently ignored > if they didn't apply to the current target. A arm compiler complains > also about a -Oppentium. -WG was one of the few examples of the group of > the -W switches which was silently ignored, probably due to historic > reasons. I think that the major problem will be trying to create a cross-platform makefile for fpc apps. I for one can create simple makefiles, but I have no idea how to add if clauses in makefiles to select the correct options for each platform.

If you don't want to use a more complex file, use either
* a project specific fpc configuration file with appropriate ifdefs
* put an $apptype directive into your main program file with appropriate ifdefs

Plus, while most options are optional, -WG is pretty much mandatory in Windows GUI apps, so you can't just live without it.

I never use -WG but always apptype, the less command line options are needed to compile a program, the easier the build method (e.g. IDE, Makefile, fpmake) can be changed.

Reply by email

Florian Klämpfl
to Florian Klämpfl
Florian Kl?mpfl wrote 14 lines
Am 14.07.2011 22:25, schrieb Felipe Monteiro de Carvalho: > On Thu, Jul 14, 2011 at 7:07 PM, Florian Kl?mpfl wrote: >> Pretty simple: most target specific switches were never silently ignored >> if they didn't apply to the current target. A arm compiler complains >> also about a -Oppentium. -WG was one of the few examples of the group of >> the -W switches which was silently ignored, probably due to historic >> reasons. > > I think that the major problem will be trying to create a > cross-platform makefile for fpc apps. I for one can create simple > makefiles, but I have no idea how to add if clauses in makefiles to > select the correct options for each platform. If you don't want to use a more complex file, use either

... complex makefile ...

Show quoted text 19 lines
* a project specific fpc configuration file with appropriate ifdefs * put an $apptype directive into your main program file with appropriate ifdefs > > Plus, while most options are optional, -WG is pretty much mandatory in > Windows GUI apps, so you can't just live without it. > I never use -WG but always apptype, the less command line options are needed to compile a program, the easier the build method (e.g. IDE, Makefile, fpmake) can be changed. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Sven Barth
to Felipe Monteiro de Carvalho: I think that the major problem will be trying to create a cross-platform makefile for fpc…
Felipe Monteiro de Carvalho wrote 15 lines
On Thu, Jul 14, 2011 at 7:07 PM, Florian Kl?mpfl wrote: > Pretty simple: most target specific switches were never silently ignored > if they didn't apply to the current target. A arm compiler complains > also about a -Oppentium. -WG was one of the few examples of the group of > the -W switches which was silently ignored, probably due to historic > reasons. I think that the major problem will be trying to create a cross-platform makefile for fpc apps. I for one can create simple makefiles, but I have no idea how to add if clauses in makefiles to select the correct options for each platform. Plus, while most options are optional, -WG is pretty much mandatory in Windows GUI apps, so you can't just live without it.

-WG might seem mandatory when you build for release, but for debugging purposes compiling a GUI application as a console one is a nice variant :D (you'll additionally get a console window)

Regards,
Sven

Reply by email

Graeme Geldenhuys
to Sven Barth
Sven Barth wrote
-WG might seem mandatory when you build for release, but for debugging purposes compiling a GUI application as a console one is a nice variant :D (you'll additionally get a console window)

That just proves that we desperately need a new debugger! ;-) My days with Delphi 4-7, I never compiler a GUI app with a console window - yet I do it daily with FPC (simply for debugging purposes).

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Flávio Etrusco
to Graeme Geldenhuys
Graeme Geldenhuys wrote 15 lines
On 07/15/2011 12:25 PM, Sven Barth wrote: > -WG might seem mandatory when you build for release, but for debugging > purposes compiling a GUI application as a console one is a nice variant > :D (you'll additionally get a console window) That just proves that we desperately need a new debugger! ;-) ?My days with Delphi 4-7, I never compiler a GUI app with a console window - yet I do it daily with FPC (simply for debugging purposes). Regards, ?- Graeme - --

Not really. At most it could indicate that we need better DebugLn support (but I don't use it, so I don't know).
Anyway, a few times I resorted to the console in Delphi (and never to Debug Log) because I needed to debug a large amount of data, or with structure, and withouts breakpoints.

-Fl?vio

Reply by email

Graeme Geldenhuys
to Flávio Etrusco

2011/7/15 Fl?vio Etrusco:

Anyway, a few times I resorted to the console in Delphi (and never to Debug Log) because I needed to debug a large amount of data, or with structure, and withouts breakpoints.

I use the tiOPF project's tiLog framework for than now. I can switch the log method (console, file, gui window, debug server) at runtime with a simple parameter. There are many Log() method call overloads/variations to help with the output generated. You can easily add that log support to any non-tiOPF based application too. This is now my primary [and most reliable] method of debugging with FPC.

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email