Recent

Author Topic: Missing conditional windows compiling switches.  (Read 762 times)

KodeZwerg

  • Hero Member
  • *****
  • Posts: 1405
  • Fifty shades of code.
    • Delphi & FreePascal
Missing conditional windows compiling switches.
« on: November 24, 2022, 07:05:50 pm »
Since my thread over here https://forum.lazarus.freepascal.org/index.php?topic=61335.msg461190#msg461190 was not successful I would have a suggestion to make for upcoming releases of Lazarus IDE.
Please do add in the .lpr file a proper way for Windows based applications.

A console application need {$APPTYPE CONSOLE} (and a GUI application can have {$APPTYPE GUI})
Of course it shall have checks like {$IFDEF MSWINDOWS} etc....

Thanks in advance!
« Last Edit: November 25, 2022, 01:04:16 am by KodeZwerg »
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 1405
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Missing conditional windows compiling switches.
« Reply #1 on: November 24, 2022, 07:15:00 pm »
Hi friend.
I tried to understand but don't understand what the hell you're talking about.
Please help friend.  :)
Since we are in the suggestions forum, there is no need for you to understand.
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 1405
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Missing conditional windows compiling switches.
« Reply #2 on: November 24, 2022, 07:40:29 pm »
Here he have an exemplar of the species Boomer Aeternus. Right, you're directing this to the top dogs only, not me, not anyone else. Sorry friend.
I apology for my rude answer, without that conditional switch a console application will having a bad end. I hope that is answer enough.
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

Bart

  • Hero Member
  • *****
  • Posts: 4981
    • Bart en Mariska's Webstek
Re: Missing conditional windows compiling switches.
« Reply #3 on: November 24, 2022, 09:24:36 pm »
You can set it in compiler options.
Uncheck Win32 GUI application in "Config and Target".

Bart

KodeZwerg

  • Hero Member
  • *****
  • Posts: 1405
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Missing conditional windows compiling switches.
« Reply #4 on: November 24, 2022, 09:30:22 pm »
You can set it in compiler options.
Uncheck Win32 GUI application in "Config and Target".

Bart
It does not add the needed line, on image i show options, i confirmed them, re-opened options to make snapshot.
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 1405
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Missing conditional windows compiling switches.
« Reply #5 on: November 24, 2022, 09:34:27 pm »
You can set it in compiler options.
Uncheck Win32 GUI application in "Config and Target".

Bart
Ahhh but it stop getting me the error 103 message and keeps console up.
Why does that config not getting applied when I select "simple application" from "Create new project"
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

PascalDragon

  • Hero Member
  • *****
  • Posts: 5081
  • Compiler Developer
Re: Missing conditional windows compiling switches.
« Reply #6 on: November 24, 2022, 10:00:27 pm »
A console application need {$APPTYPE CONSOLE} (and a GUI application can have {$APPTYPE GUI})
Of course it shall have checks like {$IFDEF MSWINDOWS} etc....

The $apptype directive is not only for Windows. And the compiler will only warn about it on platforms that don't support it. So I don't really see a use for this.

Bart

  • Hero Member
  • *****
  • Posts: 4981
    • Bart en Mariska's Webstek
Re: Missing conditional windows compiling switches.
« Reply #7 on: November 24, 2022, 10:12:20 pm »
IIRC Delphi7 dislikes ifdef's around {$apptype} directive.

Bart

Bart

  • Hero Member
  • *****
  • Posts: 4981
    • Bart en Mariska's Webstek
Re: Missing conditional windows compiling switches.
« Reply #8 on: November 24, 2022, 10:15:32 pm »
Why does that config not getting applied when I select "simple application" from "Create new project"

Not sure.
In the not so long past I did a feature request for a "default compiler setting" per project type.
That would solve this problem.
Unfortunately I have no idea how to implement something like this myself, the IDE is way to complex for me.

Bart

tetrastes

  • Sr. Member
  • ****
  • Posts: 382
Re: Missing conditional windows compiling switches.
« Reply #9 on: November 24, 2022, 10:18:52 pm »
A console application need {$APPTYPE CONSOLE}

without that conditional switch a console application will having a bad end

Why do you think so? From https://www.freepascal.org/docs-html/current/prog/progsu86.html#x94-930001.3.3
Quote
CONSOLE
A console application. A terminal will be created and standard input, output and standard error file descriptors will be initialized. In Windows, a terminal window will be created. This is the default.

When creating project for GUI (Application) Lazarus simply adds -WG (Win32 GUI application) option to project options.
So there is no need in {$APPTYPE ...}.

You can set it in compiler options.
Uncheck Win32 GUI application in "Config and Target".

Bart
Ahhh but it stop getting me the error 103 message and keeps console up.
Why does that config not getting applied when I select "simple application" from "Create new project"

What do you mean? Lazarus doesn't add -WG when creating projects for console programs.

Bart

  • Hero Member
  • *****
  • Posts: 4981
    • Bart en Mariska's Webstek
Re: Missing conditional windows compiling switches.
« Reply #10 on: November 24, 2022, 10:26:38 pm »
What do you mean? Lazarus doesn't add -WG when creating projects for console programs.

The default compiler setting on Windows is to have -WG set for all project types.
(I.o.w. the "Win32 GUI application" checkbox is checked by default in Co,piler Options->Config and Target)

Bart

KodeZwerg

  • Hero Member
  • *****
  • Posts: 1405
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Missing conditional windows compiling switches.
« Reply #11 on: November 24, 2022, 10:29:12 pm »
When I not deactivate that -WG switch or when I do not have {$APPTYPE CONSOLE} in the .lpr file,
the attachment show what happen on a Windows machine, that is the reason of why I would like to have such per default set.
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

tetrastes

  • Sr. Member
  • ****
  • Posts: 382
Re: Missing conditional windows compiling switches.
« Reply #12 on: November 24, 2022, 11:45:48 pm »
What do you mean? Lazarus doesn't add -WG when creating projects for console programs.

The default compiler setting on Windows is to have -WG set for all project types.
(I.o.w. the "Win32 GUI application" checkbox is checked by default in Co,piler Options->Config and Target)

Bart

No, unless you check "Set compiler options as default" when "Win32 GUI application" is checked (and press "OK" button, of course).
Moreover, if you do this when "Win32 GUI application" is unchecked, projects for GUI Applications will be created without -WG.
At least this is so at my Lazarus 2.2.4.
You can verify this by looking in Lazarus config folder (C:\Users\...\AppData\Local\Lazarus by default) for file projectoptions.xml. If it is there, delete it, and see how different projects are created.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 1405
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Missing conditional windows compiling switches.
« Reply #13 on: November 25, 2022, 12:07:44 am »
A console application need {$APPTYPE CONSOLE} (and a GUI application can have {$APPTYPE GUI})
Of course it shall have checks like {$IFDEF MSWINDOWS} etc....

The $apptype directive is not only for Windows. And the compiler will only warn about it on platforms that don't support it. So I don't really see a use for this.
In my thinking I more like to get a warning instead of no console appear at all when you not uncheck -WG or having the conditional active.
But okay (since you helped me on my other thread to fix that issue on my own I can live with it even if I am unsure if that be the correct behave of an IDE that should support the user)
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

Bart

  • Hero Member
  • *****
  • Posts: 4981
    • Bart en Mariska's Webstek
Re: Missing conditional windows compiling switches.
« Reply #14 on: November 25, 2022, 03:05:03 pm »
No, unless you check "Set compiler options as default" when "Win32 GUI application" is checked (and press "OK" button, of course).

That may very well be the case, since I saved and use default compiler options (with debug and release versions).

Bart

 

TinyPortal © 2005-2018