【问题标题】:How to get rid of the property grid warnings?如何摆脱属性网格警告?
【发布时间】:2016-12-21 14:09:15
【问题描述】:

我总是收到以下警告: https://gist.githubusercontent.com/jS5t3r/ccb8a6e3db18d5133d37986b8979baef/raw/f4750f5ac3211b0560d27b035d31542877669e07/warnings

我正在使用

  • ArchLinux
  • gcc (GCC) 6.2.1 20160830
  • wxwidget 3.0

我使用这些标志进行编译

WXWIDGETSFLAGS=`wx-config --gl-libs --cxxflags --libs std stc propgrid richtext` 

警告:

g++ `wx-config --gl-libs --cxxflags --libs std stc propgrid richtext`  -std=c++11 -Wall -Iinclude  source/wxwidget/GUIMemLayMgr.h source/wxwidget/gui.h source/wxwidget/GUIMemLayMgr.cpp source/wxwidget/gui.cpp  source/wxwidget/main.cpp -o output/wxwidget
In file included from /usr/include/wx-3.0/wx/propgrid/propgrid.h:26:0,
             from source/wxwidget/gui.h:31,
             from source/wxwidget/GUIMemLayMgr.h:9:
/usr/include/wx-3.0/wx/propgrid/property.h: In member function 'void  wxPGChoices::Set(const wxArrayString&, const wxArrayInt&)':
/usr/include/wx-3.0/wx/propgrid/property.h:1049:22: warning: the compiler can assume that the address of 'values' will always evaluate to 'true' [-Waddress]
     if ( &values )
                  ^
/usr/include/wx-3.0/wx/propgrid/property.h:1049:22: warning: the compiler can assume that the address of 'values' will always evaluate to 'true' [-Waddress]
In file included from /usr/include/wx-3.0/wx/propgrid/propgrid.h:26:0,
             from source/wxwidget/gui.h:31:
/usr/include/wx-3.0/wx/propgrid/property.h: In member function 'void wxPGChoices::Set(const wxArrayString&, const wxArrayInt&)':
/usr/include/wx-3.0/wx/propgrid/property.h:1049:22: warning: the compiler can assume that the address of 'values' will always evaluate to 'true' [-Waddress]
     if ( &values )
                  ^
/usr/include/wx-3.0/wx/propgrid/property.h:1049:22: warning: the compiler can assume that the address of 'values' will always evaluate to 'true' [-Waddress]
In file included from /usr/include/wx-3.0/wx/propgrid/propgrid.h:26:0,
             from source/wxwidget/gui.h:31,
             from source/wxwidget/GUIMemLayMgr.h:9,
             from source/wxwidget/GUIMemLayMgr.cpp:1:
/usr/include/wx-3.0/wx/propgrid/property.h: In member function 'void wxPGChoices::Set(const wxArrayString&, const wxArrayInt&)':
/usr/include/wx-3.0/wx/propgrid/property.h:1049:22: warning: the compiler  can assume that the address of 'values' will always evaluate to 'true' [-Waddress]
     if ( &values )
                  ^
/usr/include/wx-3.0/wx/propgrid/property.h:1049:22: warning: the compiler can assume that the address of 'values' will always evaluate to 'true' [-Waddress]
In file included from /usr/include/wx-3.0/wx/propgrid/propgrid.h:26:0,
             from source/wxwidget/gui.h:31,
             from source/wxwidget/gui.cpp:8:
/usr/include/wx-3.0/wx/propgrid/property.h: In member function 'void   wxPGChoices::Set(const wxArrayString&, const wxArrayInt&)':
/usr/include/wx-3.0/wx/propgrid/property.h:1049:22: warning: the  compiler can assume that the address of 'values' will always evaluate to 'true' [-Waddress]
     if ( &values )
                  ^
/usr/include/wx-3.0/wx/propgrid/property.h:1049:22: warning: the compiler can assume that the address of 'values' will always evaluate to 'true' [-Waddress]
In file included from /usr/include/wx-3.0/wx/propgrid/propgrid.h:26:0,
             from source/wxwidget/gui.h:31,
             from source/wxwidget/main.cpp:22:
/usr/include/wx-3.0/wx/propgrid/property.h: In member function 'void wxPGChoices::Set(const wxArrayString&, const wxArrayInt&)':
/usr/include/wx-3.0/wx/propgrid/property.h:1049:22: warning: the compiler can assume that the address of 'values' will always evaluate to 'true' [-Waddress]
     if ( &values )
                  ^
/usr/include/wx-3.0/wx/propgrid/property.h:1049:22: warning: the compiler can assume that the address of 'values' will always evaluate to 'true' [-Waddress]

【问题讨论】:

  • 不看代码很难说什么。但是它只是一个警告,如果程序运行正常,您可以忽略。
  • 您确实应该在问题中包含错误消息,而不是依赖外部链接。
  • @Igor 我不会忽略警告。

标签: compiler-errors g++ wxwidgets compiler-warnings


【解决方案1】:

这是在Optimize wxPGChoices::Set method 提交中修复的,它在3.0.2 之后。要使用它,您需要从 git 或 3.1.0 版本获取最新的 3.0 分支 - 基本上是提交之后的任何内容。

【讨论】:

  • wx-config --version 3.0.2 这个版本我用的。
  • 简短的回答是“使用3.1.0”。
【解决方案2】:

我将包含从

#include <wx/propgrid/propgrid.h>

#include <wx-3.0/wx/propgrid/propgrid.h>

现在一切正常。

【讨论】:

  • 这听起来不像是一个正确的方法。改头文件,但不使用新头文件对应的源文件是不行的。
  • 除了前面的评论说的,这并不能真正改变什么……
  • @catalin 我想,如果我使用 ,我会使用 3.0.2 之前的 wxwidget 版本。有了这个 hack hack,我正在使用 3.0.2。我该如何解决?
猜你喜欢
  • 1970-01-01
  • 2021-08-10
  • 2017-01-25
  • 1970-01-01
  • 1970-01-01
  • 2010-10-23
  • 2016-02-04
  • 2021-11-08
相关资源
最近更新 更多