[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Review Request 113189: lower (a lot) warning noise caused by undefined macros
From:       Jiří Pinkava <j-pi () seznam ! cz>
Date:       2013-10-12 23:12:40
Message-ID: 20131012231240.11747.70550 () vidsolbach ! de
[Download RAW message or body]

> On Oct. 10, 2013, 11:59 a.m., Bernd Buschinski wrote:
> > This is a bit confussing...
> > 
> > lets sum up the background story:
> > - kjs(/wtf) loves gcc features
> > - kjs-cmake filters out (gcc) pedantic
> > 
> > now comes the problem... whats with other compilers?
> > 
> > if you look at the commit message that caused the warnings:
> > 
> > "According to CPP standards (defined(X) && X) should be the same of just (X). On \
> > the other hand it is undefined behavior if 'defined' appears in a macro \
> > expansion. gcc -pedantic and icl evaluates them always to false." ( \
> > http://quickgit.kde.org/?p=kdelibs.git&a=commit&h=75fa90c16232186bbd287a2ac79839ea34da32c4 \
> > ) 
> > -> "it is undefined behavior if 'defined' appears in a macro expansion" <-
> > 
> > So? Whats the correct solution here?
> > And yes, I agree the warnings ARE annoying.
> > 
> > But I would like to hear a second opinion here :)
> 
> Michael Pyne wrote:
> IIRC when I was trying to filter out these warnings to debug some Clang issues, the \
> define flags in question are always non-zero if they are defined at all. So it \
> might be possible to replace #if with #ifdef instead.

The other option is add something like

#if !defined(SOMETHING)
#define SOMETHING 0
#endif

this is common pattern in other (non-kde) projects.


- Jiří


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/113189/#review41489
-----------------------------------------------------------


On Oct. 10, 2013, 10:52 a.m., Jiří Pinkava wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/113189/
> -----------------------------------------------------------
> 
> (Updated Oct. 10, 2013, 10:52 a.m.)
> 
> 
> Review request for kdelibs.
> 
> 
> Repository: kdelibs
> 
> 
> Description
> -------
> 
> There is a lot of warning noise in kdelibs build, this decreases number of warnings \
> a lot. 
> I have 'git grep'ped the code and checked all usages, and found no problem.
> 
> Tested by compile/usage. 
> 
> 
> Diffs
> -----
> 
> kjs/wtf/Platform.h 843cfd2 
> 
> Diff: http://git.reviewboard.kde.org/r/113189/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Jiří Pinkava
> 
> 


[Attachment #3 (text/html)]

<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;">  <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/113189/">http://git.reviewboard.kde.org/r/113189/</a>
  </td>
    </tr>
   </table>
   <br />





<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">  <p style="margin-top: 0;">On October 10th, 2013, 11:59 a.m. UTC, <b>Bernd \
Buschinski</b> wrote:</p>  <blockquote style="margin-left: 1em; border-left: 2px \
solid #d0d0d0; padding-left: 10px;">  <pre style="white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">This is a bit confussing...

lets sum up the background story:
- kjs(/wtf) loves gcc features
- kjs-cmake filters out (gcc) pedantic

now comes the problem... whats with other compilers?

if you look at the commit message that caused the warnings:

&quot;According to CPP standards (defined(X) &amp;&amp; X) should be the same of just \
(X). On the other hand it is undefined behavior if &#39;defined&#39; appears in a \
macro expansion. gcc -pedantic and icl evaluates them always to false.&quot; ( \
http://quickgit.kde.org/?p=kdelibs.git&amp;a=commit&amp;h=75fa90c16232186bbd287a2ac79839ea34da32c4 \
)

-&gt; &quot;it is undefined behavior if &#39;defined&#39; appears in a macro \
expansion&quot; &lt;-

So? Whats the correct solution here?
And yes, I agree the warnings ARE annoying.

But I would like to hear a second opinion here :)</pre>
 </blockquote>




 <p>On October 10th, 2013, 8:16 p.m. UTC, <b>Michael Pyne</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">IIRC when I was trying \
to filter out these warnings to debug some Clang issues, the define flags in question \
are always non-zero if they are defined at all. So it might be possible to replace \
#if with #ifdef instead.</pre>  </blockquote>








</blockquote>

<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The other option is add \
something like

#if !defined(SOMETHING)
#define SOMETHING 0
#endif

this is common pattern in other (non-kde) projects.</pre>
<br />










<p>- Jiří</p>


<br />
<p>On October 10th, 2013, 10:52 a.m. UTC, Jiří Pinkava wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('http://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;">  <tr>
  <td>

<div>Review request for kdelibs.</div>
<div>By Jiří Pinkava.</div>


<p style="color: grey;"><i>Updated Oct. 10, 2013, 10:52 a.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kdelibs
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">There is a lot of warning noise in kdelibs build, this decreases number \
of warnings a lot.

I have &#39;git grep&#39;ped the code and checked all usages, and found no problem.

Tested by compile/usage. </pre>
  </td>
 </tr>
</table>



<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>kjs/wtf/Platform.h <span style="color: grey">(843cfd2)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/113189/diff/" style="margin-left: \
3em;">View Diff</a></p>







  </td>
 </tr>
</table>








  </div>
 </body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic