FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour A problem with warnings
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
A problem with warnings
Posted: Mon Jun 19, 2017 03:01 PM
Compiling this sample:

Code (fw): Select all Collapse
#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 (fw): Select all Collapse
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 (fw): Select all Collapse
xHarbour 1.2.3 Intl. (SimpLex) (Build 20170513)
Copyright 1999-2017, http://www.xharbour.org <!-- m --><a class="postlink" href="http://www.harbour-project.org/">http://www.harbour-project.org/</a><!-- m -->
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
Posts: 85
Joined: Wed Nov 19, 2014 01:04 PM
Re: A problem with warnings
Posted: Mon Jun 19, 2017 03:46 PM

Dear Encrico

With /w0
I can compile the sample without any warning

Regards

Regards

Yunus



FWH 21.02
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: A problem with warnings
Posted: Mon Jun 19, 2017 04:59 PM

Thank you, but you missed the point: I do want to use /w3.

EMG

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: A problem with warnings
Posted: Mon Jun 19, 2017 08:51 PM

Enrico,

Maybe change this line:

@ 1, 1 GET cVar

To this:

@ 1, 1 GET cVar of oDlg

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: A problem with warnings
Posted: Mon Jun 19, 2017 08:58 PM
No, this is a reduced sample still showing the problem:

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

    ACTIVATE DIALOG oDlg;
             ON INIT MSGINFO();
             CENTER

    RETURN NIL


EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: A problem with warnings
Posted: Mon Jun 19, 2017 09:02 PM
The warning come from the codeblock

Code (fw): Select all Collapse
{|Self|<uInit>}


and all the other similar codeblock where we don't use all the parameters.

EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: A problem with warnings
Posted: Tue Jun 20, 2017 02:41 PM

Enrico,

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

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Guest
Posts: 0
Joined: unknown
Re: A problem with warnings
Posted: Tue Jun 20, 2017 02:45 PM

Yes, exactly (see my first post in this thread).

EMG

Posts: 88
Joined: Wed Apr 28, 2010 06:34 PM
Re: A problem with warnings
Posted: Tue Jun 20, 2017 03:29 PM

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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: A problem with warnings
Posted: Tue Jun 20, 2017 03:39 PM

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

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: A problem with warnings
Posted: Tue Jun 20, 2017 08:31 PM
/es[<level>] set exit severity
/w[<level>] set warning level number (0..3, default 1)


Strange, it only works this way.


Code (fw): Select all Collapse
   /m /n /w1 /es2
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 195
Joined: Sun Jul 22, 2012 07:01 PM
Re: A problem with warnings
Posted: Wed Jun 21, 2017 01:05 AM

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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: A problem with warnings
Posted: Wed Jun 21, 2017 07:29 AM

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

Posts: 195
Joined: Sun Jul 22, 2012 07:01 PM
Re: A problem with warnings
Posted: Wed Jun 21, 2017 03:44 PM

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

Posts: 195
Joined: Sun Jul 22, 2012 07:01 PM
Re: A problem with warnings
Posted: Wed Jun 21, 2017 04:00 PM
Using your sample, this shows exactly how I have been dealing with this in my own code.

Code (fw): Select all Collapse
#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