Sugesstion in FB

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
IBMInfo78
Posts: 3
Joined: May 16, 2022 0:08

Sugesstion in FB

Post by IBMInfo78 »

Hi,dear friend.
FreeBasic is the more powerful language,could you add converting to ISO C/C++ function,not only -gen gcc?
The C file is more diffcult to read.
angros47
Posts: 1975
Joined: Jun 21, 2005 19:04

Re: Sugesstion in FB

Post by angros47 »

FreeBasic is open source, so feel free to try adding a C++ emitter

If you try yourself, perhaps you will understand why it hasn't been done yet (what you are asking for is not trivial at all, it would require rewriting almost one third of the compiler)
marcov
Posts: 3342
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Sugesstion in FB

Post by marcov »

IBMInfo78 wrote: May 16, 2022 0:28 The C file is more diffcult to read.
It is not a converter, it is a compile backend. Backend files are not designed to be read.
srvaldez
Posts: 3009
Joined: Sep 25, 2005 21:54

Re: Sugesstion in FB

Post by srvaldez »

IBMInfo78, if you want a basic to C translator then you may be interested in BCX https://bcxbasiccoders.com/
angros47
Posts: 1975
Joined: Jun 21, 2005 19:04

Re: Sugesstion in FB

Post by angros47 »

QB64 produces C++ code, although it's not very readable
caseih
Posts: 1979
Joined: Feb 26, 2007 5:32

Re: Sugesstion in FB

Post by caseih »

It's not really possible to generate "readable" C++ code from any compiler from a different language, at least as the original poster would like to see it. You're always going to have to have extra variables kicking around, and FB runtime setup and cleanup routines surrounding common calls. And given these constraints, there's zero reason to emit C++ code as opposed to C code, and a ton or reasons not to do it. If the OP wants readable C++, he needs to write in C++ code. The only reason I can think of to emit C++ code is to more easily inter-operate with C++ libraries, something that is nearly impossible for FB to do at present. But to make FB fully interoperate with C++ is really to make FB a C++ compiler, which is probably a bad idea (and completely unrealistic).
Andrew92
Posts: 8
Joined: Apr 28, 2022 23:19

Re: Sugesstion in FB

Post by Andrew92 »

IBMInfo78 wrote: May 16, 2022 0:28 Hi,dear friend.
FreeBasic is the more powerful language,could you add converting to ISO C/C++ function,not only -gen gcc?
The C file is more diffcult to read.
I don't think that's feasible, way too much work is required probably.
Post Reply