Useful #defines and Macros

Started by Paul Squires, October 02, 2025, 10:14:00 AM

Previous topic - Next topic

Paul Squires

This may be of interest to others or maybe not. I have seen similar posts to this on the FB forum from time to time.

Having used other strongly typed programming languages such as C++ and Rust, I found that I preferred their scalar type declares more so than FreeBasic's so I now use the following at the top of my main source file.

type i8         as byte
type u8         as ubyte
type i16        as short
type u16        as ushort
type i32        as long
type u32        as ulong
type i64        as longint
type u64        as ulongint
type isize      as integer
type usize      as uinteger
type f32        as single
type f64        as double
type DWSTR      as DWSTRING       ' because I use AfxNova's DWSTRING a lot
const nullptr   as integer = 0

#define incr(i)  i+=1
#define decr(i)  i-=1

I find that using "i" "u" (eg i32 or i64) makes it much easier for me to quickly to see what size of a variable I am dealing with. I also missed PB's built in INCR and DECR.

Just sharing this in case someone else finds it useful.
 
Paul Squires
PlanetSquires Software