A problem with warnings

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

A problem with warnings

Post 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
dagiayunus
Posts: 69
Joined: Wed Nov 19, 2014 1:04 pm
Contact:

Re: A problem with warnings

Post by dagiayunus »

Dear Encrico

With /w0
I can compile the sample without any warning

Regards
Dagia Yunus.
Rajkot, India

FWH 17.04
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: A problem with warnings

Post by James Bott »

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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: A problem with warnings

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: A problem with warnings

Post 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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: A problem with warnings

Post 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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
aferra
Posts: 88
Joined: Wed Apr 28, 2010 6:34 pm

Re: A problem with warnings

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: A problem with warnings

Post 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
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: A problem with warnings

Post 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
 
João Santos - São Paulo - Brasil
User avatar
rhlawek
Posts: 165
Joined: Sun Jul 22, 2012 7:01 pm

Re: A problem with warnings

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: A problem with warnings

Post 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
User avatar
rhlawek
Posts: 165
Joined: Sun Jul 22, 2012 7:01 pm

Re: A problem with warnings

Post 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
User avatar
rhlawek
Posts: 165
Joined: Sun Jul 22, 2012 7:01 pm

Re: A problem with warnings

Post 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
 
Post Reply