-pp compiler option

Forum for discussion about the documentation project.
sancho3
Posts: 256
Joined: Sep 30, 2017 3:22

Re: -pp compiler option

Postby sancho3 » Nov 10, 2017 4:38

After some testing I think the most important thing that is missing from the description is the fact that macros are expanded.

When I first read the responses here I thought that #included files would each get their own *.pp.bas file. I see now that when you say "input source file" you are talking about additional .bas files that are going to appear on the fbc command line.
I have never compiled a program in that manner. If you use an IDE most of the time you are compiling a single file that may or may not have some #includes.

I think that the suggested change to "<source>.pp.bas" is a good one.
I like the suggested line "For every input file <source>.bas passed to the compiler, a pre-processed version named <source>.pp.bas is generated."
Perhaps adding "Note that included files and macros will be expanded in place."
Does that make sense?
fxm
Posts: 8053
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: -pp compiler option

Postby fxm » Nov 10, 2017 6:37

Proposal:
Description:
The -pp compiler option enables the preprocessor-only mode. The code is parsed & checked as usual, but is not compiled. For every input file <source>.bas passed to the compiler, a pre-processed version named <source>.pp.bas is generated.
Specifically, preprocessor commands such as conditional compilation (#if, #ifdef, #ifndef, etc.), text replacement (#define, #macro, etc.) and file inclusion (#include) are processed recursively, and the resulting expanded code is written to the pp.bas file.

Note: I think that if for each sentence the discussion is so rough, we are not ready to get even the beginning of a tutorial for beginners!
dodicat
Posts: 4951
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: -pp compiler option

Postby dodicat » Nov 10, 2017 11:08

I think most users would isolate a code file in a temp folder and apply a command line option to see what they get.
I have just tried -showincludes.
Which:
[Tells the compiler to display the file names of loaded source code files, in form of a tree. This includes the *.bas files at the toplevel, aswell as the names of #included files as they are being #included. This is intended to be used for debugging #include dependencies, etc.]

I wasn't sure what to expect (In the form of a tree!)
So the help file in this case is a teaser (encourager to test)
But testing is the only way to find out really.
fxm
Posts: 8053
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: -pp compiler option

Postby fxm » Nov 10, 2017 12:06

Tells the compiler to display the file names of loaded source code files, in form of a tree.
Tells the compiler to display the file names of loaded source code files, in form of a tree structure with indentation.
St_W
Posts: 1305
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: -pp compiler option

Postby St_W » Nov 10, 2017 14:13

dodicat wrote:I wasn't sure what to expect (In the form of a tree!)
So the help file in this case is a teaser (encourager to test)

IMHO the description is quite clear: you get *.bas files at the toplevel and the names of #included files as they are being #included.
Or do you want an exact specification how the tree view is rendered? I don't think that this is the intent of the feature. Thus I don't really like fxm's suggestion to add some description of the output format. Everybody knows what to expect when the documentation says "tree". And if not there's Wikipedia explaining such basic terms: https://en.wikipedia.org/wiki/Tree_stru ... tree_views

@dodicat: Please suggest an improved formulation/description! And I would also suggest to open a new thread for that as it's unrelated to the "-pp compiler option" topic here.
dkl
Site Admin
Posts: 3195
Joined: Jul 28, 2005 14:45
Location: Germany

Re: -pp compiler option

Postby dkl » Nov 10, 2017 16:50

It's probably easiest to put small examples (.bas files, fbc invocation, resulting output). That should set the proper expectations, shouldn't it?
fxm
Posts: 8053
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: -pp compiler option

Postby fxm » Nov 10, 2017 17:15

Is it about -showincludes or -pp or both?
dodicat
Posts: 4951
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: -pp compiler option

Postby dodicat » Nov 10, 2017 23:45

Nae fxm.
-showincludes is not allowed here.
This is a pp thread only.
PP

Suggestions?
Yea, I have some, but luckily this is a pp thread only.
deltarho[1859]
Posts: 1219
Joined: Jan 02, 2017 0:34
Location: UK

Re: -pp compiler option

Postby deltarho[1859] » Nov 11, 2017 0:38

There is one use for -pp that has not been mentioned. Well, it has actually - in the opening post but it wasn't, how can I put it, expanded upon.

PowerBASIC 'macro/end macro' block is more powerful than FreeBASIC's #Macro...#Endmacro which is simply a multi-line version of #define. I had one which clearly was not working and I spent hours trying to fathom out what I was doing wrong. The FreeBASIC -pp command line option would have been a god send.

I have just included some of my FB macros into a small bas file and made several uses of them. Needless to say the .pp.bas was smaller than the bas but what I saw would be of great help if one of my macros was not working to plan. I did the same thing were some bi files were included. Here, of course, I ended up with a very large file but my test code was at the bottom.

I think it more likely that a bug could creep into a 'heavy' PB macro than a FB macro but to be able to view a FB macro expanded could save a lot of time trying to debug an offending FB macro. Obviously, #define, with parameters, is also expanded.

So, there is a use which is not obvious from the documentation.
sancho3 wrote:I think it may also get by other people.

It got past me and, I suspect, I am not the only one. <smile>

Added: The Wiki entry is still showing source. I agree, with others above, that <source> should be used.
St_W
Posts: 1305
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: -pp compiler option

Postby St_W » Nov 11, 2017 3:43

dodicat wrote:Suggestions?
Yea, I have some, but luckily this is a pp thread only
If you don't mind to share them (and please be specific) please also don't complain. fxm is propably the only one here who doesn't just talk but actually formulates sentences and integrates them in the wiki.
fxm
Posts: 8053
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: -pp compiler option

Postby fxm » Nov 11, 2017 7:24

Some small improvements:
deltarho[1859]
Posts: 1219
Joined: Jan 02, 2017 0:34
Location: UK

Re: -pp compiler option

Postby deltarho[1859] » Nov 11, 2017 7:34

Yours truly wrote:So, there is a use which is not obvious from the documentation.

It is now.

Thanks, fxm.
fxm
Posts: 8053
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: -pp compiler option

Postby fxm » Nov 11, 2017 7:38

About macro debugging and -pp usage, see also this older topic:
dodicat
Posts: 4951
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: -pp compiler option

Postby dodicat » Nov 11, 2017 12:00

St_W wrote:
dodicat wrote:Suggestions?
Yea, I have some, but luckily this is a pp thread only
If you don't mind to share them (and please be specific) please also don't complain. fxm is propably the only one here who doesn't just talk but actually formulates sentences and integrates them in the wiki.


I do try and help in other ways in FB.
I am not prone to joining talk stuff on this forum.
Just an occasional opinion.
Also
In the past I have directed members to your library pages, your compiler updates.
I used to always get the latest build from your site.

But I stopped doing this a while back.
Also
I am not keen on being moderated by the hoi polloi.

Anyway, this is even more off topic than -showincludes.
fxm
Posts: 8053
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: -pp compiler option

Postby fxm » Nov 11, 2017 12:21

dodicat wrote:I am not keen on being moderated by the hoi polloi.
    vocabulary.com wrote:The hoi polloi is a way of referring to common people, and it is an elitist term usually used by people who consider themselves to be above the masses.
    :-(

Return to “Documentation”

Who is online

Users browsing this forum: No registered users and 1 guest