[Implemented] New compiler option: preprocess only

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: New compiler option: preprocess only

Post by uwekel »

Sounds cool.
+1
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
coco2
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Nov 25, 2013 5:38 am
Location: Australia

Re: New compiler option: preprocess only

Post by coco2 »

+1 :D
I like the idea of project code "snapshots"
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: New compiler option: preprocess only

Post by Tenaja »

PB wrote:Just found out today that this feature would save me a lot of work.
Why? I just loaded an old source of mine that used an IncludeFile.
That IncludeFile has now changed dramatically from what it was
originally, meaning the old source won't compile with it anymore.

If a pre-processor option existed, then my old source would have
had code from the old IncludeFile in it, which means I could still
compile the old code today without problem. Instead, I now have
to fix the "broken" new IncludeFile to work with it. :(

So yes, please implement a pre-processor output very soon. :)
It means that what we compile, can be forever stored as a "gold"
single source file of that app. This is extremely important.
There are not one, but two solutions that already solve the problem you have described. First, you can make a dll. Second, if you are not happy with that, you can make a library file...
http://purebasic.fr/english/viewforum.php?f=26

FWIW, the term you described would more traditionally be precompile, rather than preprocess--which is more accurately described in the first post of this thread. And unfortunately, using that definition, it would not resolve the issue of PB's evolving syntax.

BTW, there aren't really that many issues to deal with...how old is the code you are trying to compile? Why not just update it? The newer versions of PB have more efficient output than the older ones, anyway.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: New compiler option: preprocess only

Post by luis »

Tenaja wrote: There are not one, but two solutions that already solve the problem you have described.
There is no problem.

If you use an include in multiple projects, it's obvious if you change the include you have to verify all the projects using it.

If you want to freeze a project in time forever and make it independent from the include, make a private copy of the include in the project folder, and take note of the compiler version used to build the project.
Last edited by luis on Mon Feb 17, 2014 5:15 pm, edited 1 time in total.
"Have you tried turning it off and on again ?"
A little PureBasic review
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: New compiler option: preprocess only

Post by PB »

> make a private copy of the include in the project folder,
> and take note of the compiler version used to build it

Yes, hindsight is 20/20. ;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: New compiler option: preprocess only

Post by luis »

PB wrote:Yes, hindsight is 20/20. ;)
I don't see the connection here. I was merely say to tenaja there was no "problem" to overcome. Just oversight, bad planning, inexperience, call it as you like. :wink:
"Have you tried turning it off and on again ?"
A little PureBasic review
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: New compiler option: preprocess only

Post by PB »

> oversight, bad planning, inexperience

That's what the phrase "hindsight is 20/20" means. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: New compiler option: preprocess only

Post by luis »

BTW: while I like too the original request for the reasons initially stated, maybe it's not a good idea to take a "snapshot in time" this way to save you from the accidental manipulation of external dependencies. Can work in some cases but not all.
For example writing a cross platform program you would probably use a lot of compilerif, and if you try to create the snapshot you would end up with just the code "expanded" on the platform where the snapshot was created. So you have to run it multiple times on the various platforms to have different "single sources" created.
And this is just one of the possible cases.

What I mean is: the single file you would obtain from this feature wouldn't be always lossless relative to what you start with :wink:

Maybe it's easier and less error prone to just make the dependencies private to the projects by cloning them.
"Have you tried turning it off and on again ?"
A little PureBasic review
Post Reply