Page 1 of 2

A problem with warnings

Posted: Mon Jun 19, 2017 3:01 pm
by Enrico Maria Giordano
Compiling this sample:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := SPACE( 35 )

    DEFINE DIALOG oDlg

    @ 1, 1 GET cVar

    ACTIVATE DIALOG oDlg;
             ON INIT MSGINFO();
             CENTER

    RETURN NIL
I get this warning in Harbour and xHarbour:

Code: Select all

Harbour 3.2.0dev (r1605041350)
Copyright (c) 1999-2016, http://harbour-project.org/
test.prg(16) Warning W0004  Codeblock parameter 'SELF' declared but not used in function 'MAIN'
 

Code: Select all

xHarbour 1.2.3 Intl. (SimpLex) (Build 20170513)
Copyright 1999-2017, http://www.xharbour.org http://www.harbour-project.org/
test.prg(16) Warning W0004  Codeblock parameter: 'SELF' declared but not used in function: 'MAIN'
The problem is /w3 compiler switch that I want to use absolutely. In xHarbour I can use /wb- to avoid that warning but Harbour doesn't support that switch.

Any ideas?

EMG

Re: A problem with warnings

Posted: Mon Jun 19, 2017 3:46 pm
by dagiayunus
Dear Encrico

With /w0
I can compile the sample without any warning

Regards

Re: A problem with warnings

Posted: Mon Jun 19, 2017 4:59 pm
by Enrico Maria Giordano
Thank you, but you missed the point: I do want to use /w3.

EMG

Re: A problem with warnings

Posted: Mon Jun 19, 2017 8:51 pm
by James Bott
Enrico,

Maybe change this line:

@ 1, 1 GET cVar

To this:

@ 1, 1 GET cVar of oDlg

James

Re: A problem with warnings

Posted: Mon Jun 19, 2017 8:58 pm
by Enrico Maria Giordano
No, this is a reduced sample still showing the problem:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

    ACTIVATE DIALOG oDlg;
             ON INIT MSGINFO();
             CENTER

    RETURN NIL
EMG

Re: A problem with warnings

Posted: Mon Jun 19, 2017 9:02 pm
by Enrico Maria Giordano
The warning come from the codeblock

Code: Select all

{|Self|<uInit>}
and all the other similar codeblock where we don't use all the parameters.

EMG

Re: A problem with warnings

Posted: Tue Jun 20, 2017 2:41 pm
by James Bott
Enrico,

It seems that this is a valid warning, is it not? Or, are you just not wanting to see it regardless?

James

Re: A problem with warnings

Posted: Tue Jun 20, 2017 2:45 pm
by Enrico Maria Giordano
Yes, exactly (see my first post in this thread).

EMG

Re: A problem with warnings

Posted: Tue Jun 20, 2017 3:29 pm
by aferra
I found in the warning.txt in the xhb folder.

WARNING for XHB contrib users
=============================

This contrib is deprecated and not maintained anymore.

This was originally meant as a temporary stop-gap solution to help migrating
existing code written for xHarbour to Harbour, plus a means of documenting
the differences between the these two branches of the language. The
recommended path is to gradually migrate to use native core Harbour functions
and core language elements, then finalize that process by dropping the need
for this library.

Linking this library and/or using its headers (`hbcompat.ch` and `xhb.ch` in
particular) may cause various unintended side-effects both at compilation
and runtime.

Most of this code is also never tested by this fork, and none of it is ever
used, so the chances of bugs is higher than in other parts of Harbour.

If you can't do without some parts of this code, feel free to fork it locally
or publicly and continue maintaining it there, otherwise try switching to
core Harbour functionality ASAP.

-Viktor

Re: A problem with warnings

Posted: Tue Jun 20, 2017 3:39 pm
by Enrico Maria Giordano
Thank you, but I can't see how this can be of any help regarding my problem.

I repeat: I need to use /w3 warning level switch but I don't want to see all that warnings originated by codeblocks parameters (that belong to FWH and are out of my control). I use /wb- with xHarbour, how can I get the same result with Harbour?

EMG

Re: A problem with warnings

Posted: Tue Jun 20, 2017 8:31 pm
by karinha
/es[<level>] set exit severity
/w[<level>] set warning level number (0..3, default 1)


Strange, it only works this way.

Code: Select all

   /m /n /w1 /es2
 

Re: A problem with warnings

Posted: Wed Jun 21, 2017 1:05 am
by rhlawek
Enrico,

I have a couple modules where I haven't figured out what to change in the code to suppress certain warnings. I found that in harbour I can use #pragma to suppress the warning locally within the problem files.

#pragma WARNINGLEVEL = 3 // or whatever
#pragma ENABLEWARNINGS = OFF/ON

Robb

Re: A problem with warnings

Posted: Wed Jun 21, 2017 7:29 am
by Enrico Maria Giordano
Thank you, but I don't know how to suppress codeblock parameters warning in Harbour, even using compiler switches. In xHarbour I'm using /wb- but Harbour doesn't support it.

EMG

Re: A problem with warnings

Posted: Wed Jun 21, 2017 3:44 pm
by rhlawek
I don't know how to do it with a command line switch either, but with the pragmas I noted this will suppress the message for the specific section of effected code. Depending on code organization this can be a hassle to add, but does this not do what you want?

#pragma WARNINGLEVEL = 1

ACTIVATE DIALOG oDlg;
ON INIT MSGINFO();
CENTER

#pragma WARNINGLEVEL = 3

Re: A problem with warnings

Posted: Wed Jun 21, 2017 4:00 pm
by rhlawek
Using your sample, this shows exactly how I have been dealing with this in my own code.

Code: Select all

#include "Fivewin.ch"

#translate SUPPRESS_WARNING => #pragma WARNINGLEVEL = 1
#translate RESTORE_WARNING  => #pragma WARNINGLEVEL = 3

FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := SPACE( 35 )

    DEFINE DIALOG oDlg

    @ 1, 1 GET cVar

   SUPPRESS_WARNING

   ACTIVATE DIALOG oDlg;
            ON INIT MSGINFO();
            CENTER

   RESTORE_WARNING

   RETURN NIL