FreeBASIC 1.08 Development

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC 1.08 Development

Post by fxm »

Just a little supplement:
coderJeff wrote:Let's assume for a moment that we're talking about a person that is new to FreeBASIC, and also that the goal is to get this new user up and running having the least amount of knowledge possible. Maybe they are new to programming also ... it doesn't matter if we just talking about getting a program and making it do something.

WinFBE Editor and FreeBASIC Compiler (All-in-One Package) by Paul Squires
The steps are:
- download the package
- download 7-zip or something that can deal with 'rar' packages. (*)
- extract the package (*) to a directory path that does not contain space characters
- run WinFBE32 or WinFBE64
- press the 'New File' button
- paste in or type in a program in the *untitled* edit window and press CTRL+SHIFT+F5 to run it.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: FreeBASIC 1.08 Development

Post by dodicat »

Previously freebasic was bundled with fbide for starters.
Fbide is probably not the best choice now (with gcc) because of the uppercase flags required sometimes.
However the bundle by Paul Squires, WinFBE editor + freebasic looks good.
I gather you are not keen on C++, but I find it pretty neat, I have even signed up to a C++ forum.
I can get C++ from the freebasic forum (Mingw).
I use the dev C++ ide (which is written in Delphi pascal) or direct command line to G++ which I have on path, and I have My own quickrunner tweaked for C++ files.
After 15 years with fb, C++ easily falls into place, they have similarities, and If I use the inbuilt containers or string, say, I don't need to bother with new/delete/malloc e.t.c. even for OOP classes or structures.
But I must admit some C++ forum members are very big headed, I suppose they are the crème de la crème of programmers (think), Windows is written in it, Linux is written in it, most programming languages are written in it.
Anyway, I digress again.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: FreeBASIC 1.08 Development

Post by jj2007 »

To avoid spamming this one, I've opened a separate Slim FreeBasic installer for Windows thread, with a link to the latest version.
speedfixer
Posts: 606
Joined: Nov 28, 2012 1:27
Location: CA, USA moving to WA, USA
Contact:

Re: FreeBASIC 1.08 Development

Post by speedfixer »

dodicat wrote, re: C++:
Windows is written in it, Linux is written in it, most programming languages are written in it.
Almost true.
When the code is critical and really tough, it is usually just C, not C++.

C is that much more portable, and it really is THAT easy to screw up in C++ and only find out later you created a new zero-day, leak, or edge case.

david
coderJeff
Site Admin
Posts: 4326
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Post by coderJeff »

Going back to a couple earlier points... Here's my 2 cents... Paul Squires / Xusinboy please correct me if I get this wrong...

WinFBE and VisualFBEditor are both good looking programs and the code base looks good - like written by professionals. Both the IDE and framework are written completely in freebasic. This is good to see big serious programs developed using freebasic only.

WinFBE is written by Paul Squires, who I think has like 20 years experience writing editors and IDE's. And it's backed by a mature and well documented framework WinFBX by José Roca. The focus is on windows development and applications only. If you are completely new to freebasic and want to write windows applications, I think this is a very good place to start.

VisualFBEditor is relatively young, IMHO. It incorporates a different framework. One of the goals appears to be cross platform using a common framework to encapsulate windows & gtk. Overall it looks to have potential. If you are thinking you might want to write an application that can run on multiple platforms and not too concerned about windows specifics, I think this would be a good project to support.

Very respectfully, I have no desire to merge either of these IDE projects in to fbc project. But I am very happy to update links or pages that point users in the best direction.
TeeEmCee
Posts: 375
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: FreeBASIC 1.08 Development

Post by TeeEmCee »

No, "Linux" is mostly not written in C++. The kernel isn't, the GNU userspace mostly isn't. (GNOME mostly isn't, while Qt/KDE is.) The only part of the core userspace that I know of that's C++ is GCC, which switched from C pretty recently. As for programming languages, they're implemented in a wide variety of languages; I think you can think of reasons why :)

...

How about using Innosetup to create installers? I can recommend it. It uses LZMA compression (like .7z files) and is widely used, it isn't going to cause any antivirus problems (though IMO 100% of the blame falls onto the AV malware and 0% on jj2007).
You will need to use a slightly older version of Innosetup if you want to support Win XP and older, but apparently WinFBE doesn't support Win XP anyway.

BTW, it looks like the WinFBE package could be about 48MB smaller (when extracted) if it only contained 32-bit binaries. It could still compile 64-bit exes (you'd have to use a mingw build that supported crosscompiling with -m64). I don't see the point of providing 64-bit exes when 32-bit ones run on all Windows systems and aren't going to need >2GB RAM... just for some extra performance (compile speed)?
coderJeff
Site Admin
Posts: 4326
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Post by coderJeff »

I've moved a number of posts discussing WinFBE, installers and packages over to Slim FreeBasic installer for Windows. Hopefully I didn't fragment the discussions too much.
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: FreeBASIC 1.08 Development

Post by paul doe »

Would it be possible for this new release to include constants for FreeBasic's data type limits (akin to C's limits.h) as an include file? Simple, yet very useful.
coderJeff
Site Admin
Posts: 4326
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Post by coderJeff »

paul doe wrote:Would it be possible for this new release to include constants for FreeBasic's data type limits (akin to C's limits.h) as an include file? Simple, yet very useful.
It's on my wish list. hIsConstInRange() There's quite a few places in the compiler code and test suite where it would be clearer to write a test against a symbolic constant rather than a literal and would make searching for such cases easy. I was thinking we could do better than a bunch of global #defines. Maybe typed consts in a fb.limits. namespace.

Code: Select all

namespace fb.limits
	const int8_min as integer<8> = -127
	const int8_max as integer<8> = 128 
	const uint8_min as uinteger<8> = 0
	const uint8_max as uinteger<8> = 255 
	'' etc 
end namespace 
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: FreeBASIC 1.08 Development

Post by paul doe »

Whichever one is fine with me as long as the constant is immediately readable. This can also be extended for other hard limits, such as array indices, string length and array dimensions, say.
erik
Posts: 39
Joined: Dec 28, 2020 17:27
Location: Krasnoyarsk
Contact:

Re: FreeBASIC 1.08 Development

Post by erik »

Improvements:

Keyword "NullPtr" for pointers.
The "NullPtr" keyword represents a null pointer value. Use a null pointer value to indicate that an object handle, interior pointer, or native pointer type does not point to an object.
The "NullPtr" is a r-value type.

If you use the value 0 for null pointers, instead of NullPtr, then there are problems when overloading functions:

Code: Select all

foo( 0 )       ' call foo( Integer )
foo( NullPtr ) ' call foo( ZString Ptr )
There must be implicit conversions of "NullPtr" to a null pointer of any type and to a "Boolean" type (with the value False), but not to integer types.
RockTheSchock
Posts: 252
Joined: Mar 12, 2006 16:25

Re: FreeBASIC 1.08 Development

Post by RockTheSchock »

erik wrote:Keyword "NullPtr" for pointers.
Do You mean something like this?

Code: Select all

Declare Sub Test Overload (a as Integer)
Declare Sub Test Overload (a as ZString Ptr)
Declare Sub Test Overload (a as Double)


Sub Test(a as Integer)
    print a, "INTEGER"
End Sub

Sub Test (a as ZString Ptr)
    print a, "ZSTRING PTR"
End Sub

Sub Test (a as Double)
    print a, "Double"
End Sub


Const Null as Any Ptr = 0

Test 0
Test Null
Test 0.0
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: FreeBASIC 1.08 Development

Post by MrSwiss »

If I'm guessing correctly ... just "syntactic sugar" like below:

Code: Select all

' NULL-test1.bas -- (c) 2021-04-09, MrSwiss

#Ifndef NULL                            ' prevent 'duplicate definition' error
#Define NULL    0                       ' NOTE: just 'syntactic sugar'
#EndIf  ' NULL                          ' end-prevent ... 

' ===== proof of concept =====
Dim As Boolean      flag = NULL
Dim As Integer      test = NULL
Dim As Any Ptr      vptr = NULL         ' void ptr (in C parlance)
Dim As ZString Ptr  p_sz = NULL

Print "Boolean     'flag' = "; flag
Print "Integer     'test' = "; test
Print "Any Ptr     'vptr' = "; vptr
Print "ZString Ptr 'p_sz' = "; p_sz

Sleep
' ===== end - proof of concept =====
' ----- EOF -----
coderJeff
Site Admin
Posts: 4326
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Post by coderJeff »

If you like more sensitivity to NULL (0) pointer type:

Code: Select all

#ifndef NULL
	CONST NULL as any ptr = 0
#endif

dim i as integer = NULL '' warning 5(1): Implicit conversion
dim b as boolean = NULL '' warning 6(1): Implicit conversion

dim p as long ptr = NULL  '' OK
erik
Posts: 39
Joined: Dec 28, 2020 17:27
Location: Krasnoyarsk
Contact:

Re: FreeBASIC 1.08 Development

Post by erik »

coderJeff, but in "crt\stddef.bi" (includes in "windows.bi") NULL defined as:

Code: Select all

#ifndef NULL
#define NULL 0
#endif
Does this need to be corrected?
Post Reply