* * *

Author Topic: Is there a list of $IFDEF XXXXX Declarations?  (Read 22776 times)

Michael Collier

  • Full Member
  • ***
  • Posts: 233
Is there a list of $IFDEF XXXXX Declarations?
« on: January 26, 2012, 08:25:10 am »
I was wondering if there is a list of the available $IFDEF declarations?

I currently use something like

{$IFFDEF UNIX}       // mac & linux - can lazarus compile for unix?
  {$IFDEF DARWIN} // mac - powerpc & intel based
  {ELSE}                  // same as IFDEF LINUX?
  {$ENDIF}
{$ENDIF}

{$IFDEF WINDOWS} // all windows
  {$IFDEF WIN32}     // windows 32 - is there windows 64?
  {$ELSE}
{$ENDIF}

It would be helpful to know if there are others so I can include in my conditional code

e.g. maybe ANDROID , WINDOWSCE ?

xinyiman

  • Hero Member
  • *****
  • Posts: 1720
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #1 on: January 26, 2012, 08:30:03 am »
function GetOsVer: string;
begin
{$IFDEF WIN32}
 if WindowsVersion = wv95 then Result:='Windows 95'
 else if WindowsVersion = wvNT4 then Result:='Windows NT v.4'
 else if WindowsVersion = wv98 then Result:='Windows 98'
 else if WindowsVersion = wvMe then Result:='Windows ME'
 else if WindowsVersion = wv2000 then Result:='Windows 2000'
 else if WindowsVersion = wvXP then Result:='Windows XP'
 else if WindowsVersion = wvServer2003 then Result:='Windows Server 2003'
 else if WindowsVersion = wvVista then Result:='Windows Vista'
 else if WindowsVersion = wv7 then Result:='Windows 7'
 else Result:='Unknown';
{$ENDIF}
{$IFDEF UNIX}
 Result:='Linux';
{$ENDIF}
end;
Ubuntu and Mac
Lazarus: 1.8.0
FPC: 3.0.4

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6540
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #2 on: January 26, 2012, 09:52:28 am »
I was wondering if there is a list of the available $IFDEF declarations?

Basically, read the manual
http://www.freepascal.org/docs-html/prog/progap7.html#x316-331000G

Android is only experimental piggy backed on the Linux target, so that's why there is no documented define yet.

Zoran

  • Hero Member
  • *****
  • Posts: 1253
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #3 on: January 26, 2012, 10:26:27 am »
I was wondering if there is a list of the available $IFDEF declarations?

Basically, read the manual
http://www.freepascal.org/docs-html/prog/progap7.html#x316-331000G

Android is only experimental piggy backed on the Linux target, so that's why there is no documented define yet.

Plus, if you use LCL, there are defines which can determine LCL widgetset: LCLQt, LCLGtk, LCLGtk2, LCLWin32. I don't know about other LCL targets -- are there LCLfpGUI, LCLCustomdrawn defines?

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3537
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #4 on: January 26, 2012, 10:44:34 am »
For Android for now the project should define itself the ANDROID define, like the example does, until FPC has a more proper Android support.

I don't know about other LCL targets -- are there LCLfpGUI, LCLCustomdrawn defines?

Yes, all widgets get LCL defines

Michael Collier

  • Full Member
  • ***
  • Posts: 233
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #5 on: January 26, 2012, 03:15:56 pm »
Thanks, others may find this useful, maybe not, here is what I get..but ANDROID needs checking..does the LINUX/ANDROID part look correct, that is to say does ANDROID come under the LINUX definition? The rest I just extrapolated from the webpage //http://www.freepascal.org/docs-html/prog/progap7.html#x316-331000G

Code: [Select]
//http://www.freepascal.org/docs-html/prog/progap7.html#x316-331000G
// http://www.freepascal.org/docs-html/prog/progap7.html#x316-331000G
{$IFDEF UNIX              }    // --UNIX--
  {$IFDEF LINUX           }
    {$IFDEF ANDROID       }    // ANDROID
    {$ELSE}               }    // LINUX
    {$ENDIF}
  {$ENDIF}
  {$IFDEF BSD             }    // --BSD--
    {$IFDEF FREEBSD       }    // FREEBSD
    {$ENDIF}
    {$IFDEF NETBSD        }    // NETBSD
    {$ENDIF}
    {$IFDEF DARWIN        }    // Macintosh see also MAC below
    {$ENDIF}
    {$IFDEF SUNOS         }    // SUNOS
    {$ENDIF}
    {$IFDEF BEOS          }    // BEOS
    {$ENDIF}
    {$IFDEF QNX           }    // QNX
    {$ENDIF}
  {$ENDIF}
{$ENDIF}

{$IFDEF WINDOWS       }        // --WINDOWS--
  {$IFDEF WIN32       }        // WIN32
  {$ENDIF}
  {$IFDEF WIN64       }        // WIN64
  {$ENDIF}
  {$IFDEF WINCE       }        // WINCE
  {$ENDIF}
{$ENDIF}

{$IFDEF OS2         }          // --OS2--
  {$IFDEF EMX         }        // EMX
  {$ELSE}                      // OS2
  {$ENDIF}
{$ENDIF}
                               // --OTHER--
{$IFDEF GO32V2    }            // GO32V2
{$ENDIF}
{$IFDEF AMIGA     }            // Classic Amiga
{$ENDIF}
{$IFDEF ATARI     }            // Atari TOS
{$ENDIF}
{$IFDEF MAC       }            // Classic Macintosh
{$ENDIF}
{$IFDEF PALMOS    }            // PalmOS
{$ENDIF}



« Last Edit: January 26, 2012, 03:23:38 pm by Michael Collier »

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3537
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #6 on: January 26, 2012, 03:36:29 pm »
Well, this is a good question. Right now ANDROID can only appear in LINUX, but I don't know how it will be when FPC has a proper target.

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #7 on: January 26, 2012, 04:22:21 pm »
Quote

Code: [Select]
{$IFDEF BSD             }    // --BSD--
    {$IFDEF SUNOS         }    // SUNOS
    {$ENDIF}
This is not correct. BSD is not defined for SUNOS. UNIX is defined for SUNOS.

I can' test BEOS but looking at the sources BSD isn't defined neither. In compiler/systems/  you'll find i_beos, i_bsd,  etc. Search for 'extradefines'.

Michael Collier

  • Full Member
  • ***
  • Posts: 233
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #8 on: January 27, 2012, 10:27:48 am »
Thanks, my bad, this looks better I hope

Code: [Select]
// http://www.freepascal.org/docs-html/prog/progap7.html#x316-331000G
{$IFDEF UNIX              }    // --UNIX--
    {$IFDEF BEOS          }    // BEOS
    {$ENDIF}
    {$IFDEF SUNOS         }    // SUNOS
    {$ENDIF}
    {$IFDEF LINUX           }
      {$IFDEF ANDROID       }  // ANDROID
      {$ELSE}               }  // LINUX
      {$ENDIF}
    {$ENDIF}// end Linux
  {$IFDEF BSD             }    // --BSD--
    {$IFDEF FREEBSD       }    // FREEBSD
    {$ENDIF}
    {$IFDEF NETBSD        }    // NETBSD
    {$ENDIF}
    {$IFDEF DARWIN        }    // Macintosh see also MAC below
    {$ENDIF}
    {$IFDEF QNX           }    // QNX
    {$ENDIF}
  {$ENDIF}// end Bsd
{$ENDIF}// end Unix

{$IFDEF WINDOWS       }        // --WINDOWS--
  {$IFDEF WIN32       }        // WIN32
  {$ENDIF}
  {$IFDEF WIN64       }        // WIN64
  {$ENDIF}
  {$IFDEF WINCE       }        // WINCE
  {$ENDIF}
{$ENDIF}// end Windows

{$IFDEF OS2         }          // --OS2--
  {$IFDEF EMX         }        // EMX
  {$ELSE}                      // OS2
  {$ENDIF}
{$ENDIF}// end os2
                               // --OTHER--
{$IFDEF GO32V2    }            // GO32V2
{$ENDIF}
{$IFDEF AMIGA     }            // Classic Amiga
{$ENDIF}
{$IFDEF ATARI     }            // Atari TOS
{$ENDIF}
{$IFDEF MAC       }            // Classic Macintosh
{$ENDIF}
{$IFDEF PALMOS    }            // PalmOS
{$ENDIF}               


marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6540
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #9 on: January 27, 2012, 11:08:01 am »
QNX is not BSD either.

BUt better remove that from the list, afaik it hasn't been supported for 7 years or so. (was afaik never ported to the 2.0.x branch)
« Last Edit: January 27, 2012, 02:02:43 pm by marcov »

Michael Collier

  • Full Member
  • ***
  • Posts: 233
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #10 on: January 27, 2012, 01:41:43 pm »
Ok thanks

Code: [Select]
// http://www.freepascal.org/docs-html/prog/progap7.html#x316-331000G
// Note: QNX removed as it hasn't been supported for several years.
{$IFDEF UNIX              }    // --UNIX--
    {$IFDEF BEOS          }    // BEOS
    {$ENDIF}
    {$IFDEF SUNOS         }    // SUNOS
    {$ENDIF}
    {$IFDEF LINUX           }
      {$IFDEF ANDROID       }  // ANDROID
      {$ELSE}               }  // LINUX
      {$ENDIF}
    {$ENDIF}// end Linux
  {$IFDEF BSD             }    // --BSD--
    {$IFDEF FREEBSD       }    // FREEBSD
    {$ENDIF}
    {$IFDEF NETBSD        }    // NETBSD
    {$ENDIF}
    {$IFDEF DARWIN        }    // Macintosh see also MAC below
    {$ENDIF}
  {$ENDIF}// end Bsd
{$ENDIF}// end Unix

{$IFDEF WINDOWS       }        // --WINDOWS--
  {$IFDEF WIN32       }        // WIN32
  {$ENDIF}
  {$IFDEF WIN64       }        // WIN64
  {$ENDIF}
  {$IFDEF WINCE       }        // WINCE
  {$ENDIF}
{$ENDIF}// end Windows

{$IFDEF OS2         }          // --OS2--
  {$IFDEF EMX         }        // EMX
  {$ELSE}                      // OS2
  {$ENDIF}
{$ENDIF}// end os2
                               // --OTHER--
{$IFDEF GO32V2    }            // GO32V2
{$ENDIF}
{$IFDEF AMIGA     }            // Classic Amiga
{$ENDIF}
{$IFDEF ATARI     }            // Atari TOS
{$ENDIF}
{$IFDEF MAC       }            // Classic Macintosh
{$ENDIF}
{$IFDEF PALMOS    }            // PalmOS
{$ENDIF}           

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6540
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #11 on: January 27, 2012, 02:04:21 pm »
Oh, and trunk and fixes 2.6.x support openbsd. Which is a BSD :-)

NetBSD is currently sleeping. But I believe Pierre is looking into it.    NetBSD/powerpc was quickported to 1.9.2, but not really maintained.

Michael Collier

  • Full Member
  • ***
  • Posts: 233
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #12 on: January 27, 2012, 02:23:33 pm »
OpenBsd sounds interesting, I found this page to dual boot a few BSD based platforms and it mentions openBSD http://geodsoft.com/howto/dualboot/ so I may as well go ahead and install openBSD with the rest so I can test lazarus in the future?


marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6540
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #13 on: January 27, 2012, 02:39:30 pm »
OpenBsd sounds interesting, I found this page to dual boot a few BSD based platforms and it mentions openBSD http://geodsoft.com/howto/dualboot/ so I may as well go ahead and install openBSD with the rest so I can test lazarus in the future?

In theory, yes. Depending on how able you are in building own FPCs (there is no release yet)

mdalacu

  • Full Member
  • ***
  • Posts: 183
    • dmSimpleApps
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #14 on: April 02, 2014, 10:04:07 am »
How can i find if the Linux  OS is 32 or 64 bit from compile directives. Thx.
« Last Edit: April 02, 2014, 10:18:09 am by mdalacu »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus