Recent

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

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #15 on: April 02, 2014, 10:58:23 am »
How can i find if the Linux  OS is 32 or 64 bit from compile directives. Thx.

Test CPU64. Works for all 64-bit CPUs (so also e.g. powerpc64)

For 32-bit there is CPU32, and in trunk also CPU16, and maybe one day CPU8.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #16 on: April 02, 2014, 04:24:30 pm »
This won't really help if your Linux is 64 bit running a 32 bit program, right...?

I found a trick for Windows:
http://wiki.lazarus.freepascal.org/Multiplatform_Programming_Guide#Detecting_bitness_at_runtime
Perhaps there's something comparable for Linux...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #17 on: April 02, 2014, 06:50:18 pm »
This won't really help if your Linux is 64 bit running a 32 bit program, right...?

My userland is then still 32-bit and that is usually all one cares about. Detecting 64-bit kernel is a different question IMHO

Detecting that is also not compiletime possible, and this thread is about compiletime defines.


mdalacu

  • Full Member
  • ***
  • Posts: 233
    • dmSimpleApps
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #18 on: April 03, 2014, 10:08:40 am »
How can i find if the Linux  OS is 32 or 64 bit from compile directives. Thx.

Test CPU64. Works for all 64-bit CPUs (so also e.g. powerpc64)

For 32-bit there is CPU32, and in trunk also CPU16, and maybe one day CPU8.
Thank you for this, but i didn't have time to test this.
So, this will work if you have an 32 bit linux installed on a 64-bit capable processor? It will state that CPU32 is true?
Thanks again.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #19 on: April 03, 2014, 04:28:13 pm »
Quote
So, this will work if you have an 32 bit linux installed on a 64-bit capable processor? It will state that CPU32 is true?
Yes, it's the target that matters, not what the processor is capable of.

karaba

  • New Member
  • *
  • Posts: 49
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #20 on: April 06, 2014, 10:32:52 am »
How can i find if the Linux  OS is 32 or 64 bit from compile directives. Thx.

You can't the compile directive tell you what you are going to produce if anything not what system you are on.

http://www.freepascal.org/docs-html/prog/progap7.html#x316-331000G
« Last Edit: April 06, 2014, 11:04:27 am by karaba »

mdalacu

  • Full Member
  • ***
  • Posts: 233
    • dmSimpleApps
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #21 on: April 16, 2014, 01:23:21 pm »
Quote
So, this will work if you have an 32 bit linux installed on a 64-bit capable processor? It will state that CPU32 is true?
Yes, it's the target that matters, not what the processor is capable of.
Thank you , i have tested it and it is working.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 663
    • My games in Pascal
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #22 on: February 03, 2018, 08:39:40 am »
Still an issue in 2018... I hope nobody is against raising from the dead a topic and looking for a complete set of OS-specific FPC defines...?
I've searched through the src and it has no explicit define Android or define Linux anywhere.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

Thaddy

  • Hero Member
  • *****
  • Posts: 14210
  • Probably until I exterminate Putin.
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #23 on: February 03, 2018, 09:00:46 am »
They are in the systems directory in the compiler tree, but not so easy to distill as it is per platform and there are dependencies (extradefines: e.g. linux also defines unix)
The easiest way to obtain them is typing fpc -i or ppcrossxxx -i e.d.
IOW: there is no list but the compiler can show you which defines are applicable for which specific compiler.

The compiler defines - I believe - come from e.g.:
Code: Pascal  [Select][+][-]
  1.        system_aarch64_linux_info  : tsysteminfo =
  2.           (
  3.             system       : system_aarch64_linux;
  4.             name         : 'Linux for AArch64';
  5.             shortname    : 'Linux';
  6.             flags        : [tf_needs_symbol_size,
  7.                             tf_needs_symbol_type,
  8.                             tf_files_case_sensitive,
  9.                             tf_requires_proper_alignment,
  10.                             tf_smartlink_sections,tf_pic_uses_got,
  11.                             tf_has_winlike_resources];
  12.             cpu          : cpu_aarch64;
  13.             unit_env     : 'LINUXUNITS';
  14.             extradefines : 'UNIX;HASUNIX';

And FPC -i will give you:
Code: Bash  [Select][+][-]
  1. Compiler CPU target: arm
  2.  
  3. Supported targets (targets marked with '{*}' are under development):
  4.   Linux: Linux for ARMHF
  5.   WinCE: WinCE for ARM
  6.   gba: GameBoy Advance
  7.   PalmOS: PalmOS
  8.   nds: Nintendo DS
  9.   embedded: Embedded
  10.   Symbian: Symbian OS for ARM
  11.   Darwin: Darwin for ARM
  12.   Android: Android for ARMEL
  13.   AROS: AROS for ARM
  14.  
  15. Supported CPU instruction sets:
  16.   ARMV3,ARMV4,ARMV4T,ARMV5,ARMV5T,ARMV5TE,ARMV5TEJ,ARMV6,ARMV6K,ARMV6T2
  17.   ARMV6Z,ARMV6M,ARMV7,ARMV7A,ARMV7R,ARMV7M,ARMV7EM
  18.  
  19. Supported FPU instruction sets:
  20.   SOFT,LIBGCC,FPA,FPA10,FPA11,VFPV2,VFPV3,VFPV3_D16,FPV4_S16,VFPV4
  21.  
Which can all be used as defines.
« Last Edit: February 03, 2018, 09:10:15 am by Thaddy »
Specialize a type, not a var.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #24 on: February 03, 2018, 01:07:55 pm »
Alternatively you can compile a simple program or unit with the "-vc" parameter which prints all defined conditionals for that run. E.g. for fpc 3.0.4 on x86_64-linux the result will be this:

Code: [Select]
Macro defined: LINUX
Macro defined: UNIX
Macro defined: HASUNIX
Macro defined: FPC_HAS_WINLIKERESOURCES
Macro defined: CONSOLE
Macro defined: LINUX
Macro defined: FPC
Macro defined: VER3
Macro defined: VER3_0
Macro defined: VER3_0_4
Macro defined: RESSTRSECTIONS
Macro defined: FPC_HASFIXED64BITVARIANT
Macro defined: FPC_HASINTERNALOLEVARIANT2VARIANTCAST
Macro defined: FPC_HAS_VARSETS
Macro defined: FPC_HAS_VALGRINDBOOL
Macro defined: FPC_HAS_STR_CURRENCY
Macro defined: FPC_REAL2REAL_FIXED
Macro defined: FPC_STRTOCHARARRAYPROC
Macro defined: FPC_STRTOSHORTSTRINGPROC
Macro defined: FPC_OBJFPC_EXTENDED_IF
Macro defined: FPC_HAS_OPERATOR_ENUMERATOR
Macro defined: FPC_HAS_CONSTREF
Macro defined: FPC_STATICRIPFIXED
Macro defined: FPC_VARIANTCOPY_FIXED
Macro defined: FPC_DYNARRAYCOPY_FIXED
Macro defined: FPC_HAS_INTERNAL_ABS_LONG
Macro defined: FPC_HAS_INTERNAL_ABS_INT64
Macro defined: FPC_HAS_UNICODESTRING
Macro defined: FPC_RTTI_PACKSET1
Macro defined: FPC_HAS_CPSTRING
Macro defined: FPC_HAS_RIP_RELATIVE
Macro defined: FPC_HAS_CEXTENDED
Macro defined: FPC_HAS_RESSTRINITS
Macro defined: FPC_HAS_INTERNAL_ROX
Macro defined: FPC_HAS_INTERNAL_SAR
Macro defined: FPC_HAS_MEMBAR
Macro defined: FPC_SETBASE_USED
Macro defined: INTERNAL_BACKTRACE
Macro defined: STR_CONCAT_PROCS
Macro defined: REGCALL
Macro defined: FPC_HAS_FEATURE_SUPPORT
Macro defined: CPUX86_64
Macro defined: CPUAMD64
Macro defined: CPU64
Macro defined: CPUX64
Macro defined: ENDIAN_LITTLE
Macro defined: FPC_LITTLE_ENDIAN
Macro defined: FPC_ABI_DEFAULT
Free Pascal Compiler version 3.0.4 [2017/10/03] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Macro defined: CPUATHLON64
Macro defined: FPUSSE64
Macro defined: CPUX86_HAS_SSEUNIT
Macro defined: FPC_HAS_TYPE_SINGLE
Macro defined: FPC_HAS_TYPE_DOUBLE
Macro defined: FPC_HAS_TYPE_EXTENDED
Macro defined: FPC_HAS_INTERNAL_BSF
Macro defined: FPC_HAS_INTERNAL_BSR
Macro defined: FPC_LINK_STATIC
Macro FPC_VERSION set to 3
Macro FPC_RELEASE set to 0
Macro FPC_PATCH set to 4
Macro FPC_FULLVERSION set to 30004
Macro defined: FPC_WIDESTRING_EQUAL_UNICODESTRING
Macro defined: FPC_HAS_FEATURE_HEAP
Macro defined: FPC_HAS_FEATURE_INITFINAL
Macro defined: FPC_HAS_FEATURE_RTTI
Macro defined: FPC_HAS_FEATURE_CLASSES
Macro defined: FPC_HAS_FEATURE_EXCEPTIONS
Macro defined: FPC_HAS_FEATURE_EXITCODE
Macro defined: FPC_HAS_FEATURE_ANSISTRINGS
Macro defined: FPC_HAS_FEATURE_WIDESTRINGS
Macro defined: FPC_HAS_FEATURE_TEXTIO
Macro defined: FPC_HAS_FEATURE_CONSOLEIO
Macro defined: FPC_HAS_FEATURE_FILEIO
Macro defined: FPC_HAS_FEATURE_RANDOM
Macro defined: FPC_HAS_FEATURE_VARIANTS
Macro defined: FPC_HAS_FEATURE_OBJECTS
Macro defined: FPC_HAS_FEATURE_DYNARRAYS
Macro defined: FPC_HAS_FEATURE_THREADING
Macro defined: FPC_HAS_FEATURE_COMMANDARGS
Macro defined: FPC_HAS_FEATURE_PROCESSES
Macro defined: FPC_HAS_FEATURE_STACKCHECK
Macro defined: FPC_HAS_FEATURE_DYNLIBS
Macro defined: FPC_HAS_FEATURE_SOFTFPU
Macro defined: FPC_HAS_FEATURE_OBJECTIVEC1
Macro defined: FPC_HAS_FEATURE_RESOURCES
Macro defined: FPC_HAS_FEATURE_UNICODESTRINGS
Target OS: Linux for x86-64
Compiling ./fpctests/tdefinetest.pp
Linking testoutput/tdefinetest
/usr/bin/ld: warning: testoutput/link.res contains output sections; did you forget -T?
5 lines compiled, 0.3 sec

Eugene Loza

  • Hero Member
  • *****
  • Posts: 663
    • My games in Pascal
Re: Is there a list of $IFDEF XXXXX Declarations?
« Reply #25 on: February 04, 2018, 03:08:30 pm »
PascalDragon, Thaddy, thanks! That makes things much more clear.
However, still, knowing which directives are defined on Linux is nice, but which directives would be defined on an Android phone or Mac desktop? I can't run fpc -vc or fpc -i there... Just trying to do cross-compilation.

(UPD) Hmm... a cross-compiler should display those correctly (as they're working compile-time, so I don't need to have FPC installed at the target)! I'll try it.
« Last Edit: February 04, 2018, 05:05:21 pm by Eugene Loza »
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)


 

TinyPortal © 2005-2018