This piece of code: https://github.com/3oheicrw/SGL-FreeBAS ... l_test.bas
Currently I hard coded it to link with "sgl64". I want something like this:
if 32 bit windows then link with "sgl32"
if 64 bit windows then link with "sgl64"
else error not supported
Please help.
Conditional compilation
Re: Conditional compilation
in the FB help file search for __FB and you will get helpful information, for example
Code: Select all
#ifdef __FB_64BIT__
'...instructions for 64bit OSes...
#else
'...instructions for other OSes
#endif
Re: Conditional compilation
I come up with something crazy like this. Hope someone could help me to optimize/simplify it.
Code: Select all
#ifdef __FB_WIN32__
#ifdef __FB_X86__
#ifdef __FB_64BIT__
#inclib "sgl64"
#else
#inclib "sgl32"
#endif
#else
#error Unsupported architecture
#endif
#else
#error Unsupported OS
#endif
-
- Posts: 789
- Joined: Jul 26, 2018 18:28
Re: Conditional compilation
So:
Code: Select all
#ifdef __FB_WIN32__
#ifdef __FB_64BIT__
#inclib "sgl64"
#else
#inclib "sgl32"
#endif
#else
#error Unsupported OS
#endif
Re: Conditional compilation
Is it enough? Windows now supports ARM too. __FB_64BIT__ only tells you it's 64 bit or not but it's not equivalent to x86_64, it could be arm64.Xusinboy Bekchanov wrote: ↑Apr 04, 2022 3:57So:Code: Select all
#ifdef __FB_WIN32__ #ifdef __FB_64BIT__ #inclib "sgl64" #else #inclib "sgl32" #endif #else #error Unsupported OS #endif
-
- Posts: 789
- Joined: Jul 26, 2018 18:28
Re: Conditional compilation
In general, only use the ELSE clause for the errors, never assume anything about the ELSE clause.
Name all other ones explicitly.
Code like above only inspires people to write a 16-bit port.
Name all other ones explicitly.
Code like above only inspires people to write a 16-bit port.