Harbour warnings

Harbour warnings

Postby Enrico Maria Giordano » Thu Jun 23, 2022 3:52 pm

Hi all!

How to suppress this unuseful warning without suppress all the warnings using Harbour? With xHarbour we have -wb- compiler switch.

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

    ACTIVATE DIALOG oDlg;
             ON INIT MSGINFO();
             CENTER

    RETURN NIL


Code: Select all  Expand view
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
test.prg(12) Warning W0004  Codeblock parameter 'SELF' declared but not used in function 'MAIN'

No code generated.


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Harbour warnings

Postby hmpaquito » Fri Jun 24, 2022 9:25 am

Mr. Enrico

Suppresses all compiler switch -w? (-w, -w1, -w2, -w3) or set -w (-w1)

Regards
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Harbour warnings

Postby Enrico Maria Giordano » Fri Jun 24, 2022 9:33 am

Thank you, but I don't want to suppress all the compiler warnings, only this one:

Code: Select all  Expand view
Warning W0004  Codeblock parameter 'SELF' declared but not used in function 'MAIN'


Please note that there is nothing visible in the source code that can cause that warning.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Harbour warnings

Postby hmpaquito » Fri Jun 24, 2022 10:12 am

Enrico Maria Giordano wrote:
Please note that there is nothing visible in the source code that can cause that warning.

EMG


Hi,

Fivewin .ch files generates codeblock {|Self| xxxxxxx }
Look at in test.ppo file

Regards
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Harbour warnings

Postby Enrico Maria Giordano » Fri Jun 24, 2022 10:16 am

Yes, I know it, but this doesn't solve the problem. I don't want to see a warning that I can't fix.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Harbour warnings

Postby hmpaquito » Fri Jun 24, 2022 10:48 am

Enrico Maria Giordano wrote:Yes, I know it, but this doesn't solve the problem. I don't want to see a warning that I can't fix.

EMG


I think that is impossible without new clausules introduction on Fwh commands because to be must respect legacy code
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Harbour warnings

Postby Enrico Maria Giordano » Fri Jun 24, 2022 11:02 am

As I wrote in the first message, with xHarbour I use the -wb- compiler switch. I hoped there were something similar in Harbour.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Harbour warnings

Postby hmpaquito » Fri Jun 24, 2022 4:16 pm

Hi Mr. Enrico,

IMHO -wb- is not a xHarbour valid switch.

Regards



d:\xPrueba>dir
El volumen de la unidad D no tiene etiqueta.
El número de serie del volumen es: 363E-D9F4

Directorio de d:\xPrueba

24/06/2022 18:10 <DIR> .
24/06/2022 18:10 <DIR> ..
14/12/2020 21:47 699.392 harbour.exe
24/06/2022 17:50 54 prueba.prg
14/12/2020 21:51 3.745.792 xharbour.dll


d:\xPrueba>harbour
xHarbour 1.2.3 Intl. (SimpLex) (Build 20201212)
Copyright 1999-2020, http://www.xharbour.org http://www.harbour-project.org/

Syntax: d:\xPrueba\harbour.exe <file[s][.prg]> [options]

Options: /a automatic memvar declaration
/b debug info
/build display detailed version info
/credits display credits
/d<id>[=<val>] #define <id>
/es[<level>] set exit severity
/ex create public function list (.xbx)
/g<type> output type generated is <type> (see below)
/gc[<type>] output type: C source (.c) (default)
<type>: 0=compact 1=normal 2=verbose (default)
3=generate real C code
/go output type: Platform dependant object module
/gh output type: Harbour Portable Object (.hrb)
/i<path> #include file search path
/j[<file>] output i18n support [to <file>] to .hil
/k compilation mode (type -k? for more data)
/l suppress line number information
/m compile module only
/n[<type>] no implicit starting procedure (default)
<type>: 0=no implicit starting procedure
1=no starting procedure at all
2=force application starting procedure
/o<path> object file drive and/or path
/p[o<path>] generate pre-processed output (.ppo) file in <path>
/pt[o<path>] generate pre-processor trace (.ppt) file in <path>
/q quiet
/q0 quiet and don't display program header
/s syntax check only
/u[[+]<file>] use command def set in <file> (or none)
/undef:<id> #undef <id>
/v variables are assumed M->
/vd external functions are assumed as dynamic functions
/w[<level>] set warning level number (0..3, default 1)
/x[<prefix>] set symbol init function name prefix (for .c only)
/z suppress shortcutting (.and. & .or.)
@<file> compile list of modules in <file>


d:\xPrueba>type prueba.prg
function main()

a:= {|self| "hola" }
return nil


d:\xPrueba>harbour prueba
xHarbour 1.2.3 Intl. (SimpLex) (Build 20201212)
Copyright 1999-2020, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'prueba.prg'...
Generating C source output to 'prueba.c'...
Done.
Lines 6, Functions/Procedures 2, pCodes 9

d:\xPrueba>harbour prueba -w
xHarbour 1.2.3 Intl. (SimpLex) (Build 20201212)
Copyright 1999-2020, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'prueba.prg'...
prueba.prg(3) Warning W0001 Ambiguous reference: 'A'
Generating C source output to 'prueba.c'...
Done.
Lines 6, Functions/Procedures 2, pCodes 9

d:\xPrueba>harbour prueba -w2
xHarbour 1.2.3 Intl. (SimpLex) (Build 20201212)
Copyright 1999-2020, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'prueba.prg'...
prueba.prg(3) Warning W0004 Codeblock parameter: 'SELF' declared but not used in function: 'MAIN'
prueba.prg(3) Warning W0001 Ambiguous reference: 'A'
Generating C source output to 'prueba.c'...
Done.
Lines 6, Functions/Procedures 2, pCodes 9

d:\xPrueba>harbour prueba -wb
xHarbour 1.2.3 Intl. (SimpLex) (Build 20201212)
Copyright 1999-2020, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'prueba.prg'...
prueba.prg(3) Warning W0004 Codeblock parameter: 'SELF' declared but not used in function: 'MAIN'
prueba.prg(3) Warning W0001 Ambiguous reference: 'A'
Generating C source output to 'prueba.c'...
Done.
Lines 6, Functions/Procedures 2, pCodes 9

d:\xPrueba>harbour prueba -wb-
xHarbour 1.2.3 Intl. (SimpLex) (Build 20201212)
Copyright 1999-2020, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'prueba.prg'...
Generating C source output to 'prueba.c'...
Done.
Lines 6, Functions/Procedures 2, pCodes 9

d:\xPrueba>
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Harbour warnings

Postby rhlawek » Fri Jun 24, 2022 5:28 pm

I've been doing this. I'm not sure it is completely perfect as it appears (to me) that once set to level 1 this way the reset back to level 3 doesn't always seem to work.

Code: Select all  Expand view

#pragma WARNINGLEVEL = 1

// Warning generating code...

#pragma WARNINGLEVEL = 3

 
User avatar
rhlawek
 
Posts: 193
Joined: Sun Jul 22, 2012 7:01 pm

Re: Harbour warnings

Postby Enrico Maria Giordano » Fri Jun 24, 2022 5:44 pm

hmpaquito wrote:Hi Mr. Enrico,

IMHO -wb- is not a xHarbour valid switch.


Sure it is, I'm using it all the time, since years.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Harbour warnings

Postby Enrico Maria Giordano » Fri Jun 24, 2022 5:46 pm

rhlawek wrote:I've been doing this. I'm not sure it is completely perfect as it appears (to me) that once set to level 1 this way the reset back to level 3 doesn't always seem to work.

Code: Select all  Expand view

#pragma WARNINGLEVEL = 1

// Warning generating code...

#pragma WARNINGLEVEL = 3

 


The problem here is that the code generating the warning is not in my source code. Please look at my sample in the first message of this thread.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Harbour warnings

Postby rhlawek » Fri Jun 24, 2022 6:01 pm

I don't think I understand. This is the sample you provided when you started this thread, with the addition as I use it to ignore this specific warning. If not this code, what code are you talking about?

Code: Select all  Expand view

#include "Fivewin.ch"

FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

#pragma WARNINGLEVEL = 1

    ACTIVATE DIALOG oDlg;
             ON INIT MSGINFO();
             CENTER

    RETURN NIL
 
User avatar
rhlawek
 
Posts: 193
Joined: Sun Jul 22, 2012 7:01 pm

Re: Harbour warnings

Postby Enrico Maria Giordano » Fri Jun 24, 2022 7:29 pm

Are you suggesting that I have to put the pragmas around any code that can cause a warning? If it were my code I will fix it. But something like this

Code: Select all  Expand view
   ACTIVATE DIALOG oDlg;
             ON INIT MSGINFO();
             CENTER


doesn't have any visible code that can cause a warning that I can fix. The warning is caused by the FWH code that is the result of preprocessing command directive. So I can't fix it. And surely I don't want to put all the pragmas you suggested. How do you deal with this problem in your programs?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Harbour warnings

Postby rhlawek » Fri Jun 24, 2022 7:53 pm

Yes, unfortunately. I know inserting this throughout any code base could be a hassle but, yes, this is exactly what I have done. If I cant' fix something just via code (always my preference) I may hide the error using an HB_SYMBOL_UNUSED() call at the end of a func/proc and only use the pragma as a last resort.

I tend to keep all my fivewin code isolated from my pure harbour code, so it actually isn't a huge problem for me, but then again I did it years ago and have maintained that practice. My practice is to fix anything/everything that I can fix for warnings thrown when using -W3, including using HB_SYMBOL_UNUSED() where it is applicable, then only use the pragma to fix what is left. I'm always looking for a better answer, but so far this is the best I've come up with.

I'll say again, I know using the pragma to change to w1 works, but a following call to set back to w3 doesn't always work. I've always assumed this is a harbour bug of some sort but I've never tried to track it down.
User avatar
rhlawek
 
Posts: 193
Joined: Sun Jul 22, 2012 7:01 pm

Re: Harbour warnings

Postby hmpaquito » Fri Jun 24, 2022 7:56 pm

Enrico Maria Giordano wrote:
rhlawek wrote:I've been doing this. I'm not sure it is completely perfect as it appears (to me) that once set to level 1 this way the reset back to level 3 doesn't always seem to work.

Code: Select all  Expand view

#pragma WARNINGLEVEL = 1

// Warning generating code...

#pragma WARNINGLEVEL = 3

 


The problem here is that the code generating the warning is not in my source code. Please look at my sample in the first message of this thread.

EMG



Nope.

My first answer was definitiva: I tell you
I think that is impossible without new clausules introduction on Fwh commands because to be must respect legacy code



And then you say:

As I wrote in the first message, with xHarbour I use the -wb- compiler switch. I hoped there were something similar in Harbour.



And then I say:
IMHO -wb- is not a xHarbour valid switch.



And then you say again:
The problem here is that the code generating the warning is not in my source code. Please look at my sample in the first message of this thread.



Which of my answers did you not understand?
And now my question is, is it worth helping when he answers you like a fronton?
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Otto and 61 guests