标签: warnings

为什么要始终启用编译器警告?

我经常听到,在编译C和C ++程序时,我应该“始终启用编译器警告”。为什么这是必要的?我怎么做?

有时我也听说我应该“将警告视为错误”。我是不是该?我怎么做?

c c++ warnings c++-faq compiler-warnings

292
推荐指数
15
解决办法
3万
查看次数

如何在PHP中处理file_get_contents()函数的警告?

我写了这样的PHP代码

$site="http://www.google.com";
$content = file_get_content($site);
echo $content;
Run Code Online (Sandbox Code Playgroud)

但当我删除"http://"时,$site我收到以下警告:

警告:file_get_contents(www.google.com)[function.file-get-contents]:无法打开流:

我尝试过try,catch但它没有用.

php warnings exception-handling function

290
推荐指数
9
解决办法
30万
查看次数

是什么导致javac发出"使用未经检查或不安全的操作"警告

例如:

javac Foo.java
Note: Foo.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Run Code Online (Sandbox Code Playgroud)

java generics warnings

267
推荐指数
7
解决办法
37万
查看次数

隐藏ipython中的所有警告

我需要制作一个ipython会话的截屏视频,并且为了避免混淆观众,我想禁用warnings.warn来自不同包的调用发出的所有警告.有没有办法配置ipythonrc文件来自动禁用所有这些警告?

python warnings ipython

255
推荐指数
4
解决办法
23万
查看次数

Java中有效的@SuppressWarnings警告名称列表是什么?

@SuppressWarningsJava 中有效警告名称的列表是什么?

进来之间的("")@SuppressWarnings("").

java eclipse warnings compiler-warnings suppress-warnings

251
推荐指数
5
解决办法
14万
查看次数

避免将null作为视图根传递(需要解析膨胀布局的根元素上的布局参数)

为root studio传递null给了我这个警告:

避免将null作为视图根传递(需要解析膨胀布局的根元素上的布局参数)

它显示为空值getGroupView.请帮忙.

public class ExpandableListAdapter extends BaseExpandableListAdapter {

    private Context _context;
    private List<String> _listDataHeader; // header titles
    // child data in format of header title, child title
    private HashMap<String, List<String>> _listDataChild;

    public ExpandableListAdapter(Context context, List<String> listDataHeader,
                                 HashMap<String, List<String>> listChildData) {
        super();
        this._context = context;
        this._listDataHeader = listDataHeader;
        this._listDataChild = listChildData;
    }

    @Override
    public Object getChild(int groupPosition, int childPosititon) {
        return this._listDataChild.get(this._listDataHeader.get(groupPosition))
                .get(childPosititon);
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    @Override
    public …
Run Code Online (Sandbox Code Playgroud)

android warnings android-layout layout-inflater

218
推荐指数
6
解决办法
8万
查看次数

如何最好地消除有关未使用变量的警告?

我有一个跨平台应用程序,在我的一些函数中,并没有使用传递给函数的所有值.因此我收到GCC的警告,告诉我有未使用的变量.

编码警告的最佳编码方式是什么?

围绕这个功能的#ifdef?

#ifdef _MSC_VER
void ProcessOps::sendToExternalApp(QString sAppName, QString sImagePath, qreal qrLeft, qreal qrTop, qreal qrWidth, qreal qrHeight)
#else
void ProcessOps::sendToExternalApp(QString sAppName, QString sImagePath, qreal /*qrLeft*/, qreal /*qrTop*/, qreal /*qrWidth*/, qreal /*qrHeight*/)
#endif
{
Run Code Online (Sandbox Code Playgroud)

这太丑了,但似乎是编译器喜欢的方式.

或者我在函数末尾为变量赋值为零?(我讨厌它,因为它改变了程序流程中的某些东西以使编译器警告静音).

有正确的方法吗?

c++ gcc warnings gcc-warning

212
推荐指数
13
解决办法
17万
查看次数

XML中"缺少图像上的contentDescription属性"

我在eclipse中的图像上收到关于[辅助功能]缺少contentDescription属性的警告.此警告显示在ImageView下面的XML代码中的第5行(声明).

这在构建和运行我的应用程序时不会出现任何错误.但我真的想知道为什么我会收到这个警告.

这是我的XML文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/contact_entry_image"
        android:src="@drawable/ic_launcher"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />
    <TextView
        android:id="@+id/contact_entry_text"
        android:text=""
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="30sp"
        />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

请帮我解决这个问题并感谢您的阅读.

eclipse android warnings accessibility android-imageview

207
推荐指数
8
解决办法
26万
查看次数

删除PHP中的警告消息

我有一些PHP代码.当我运行它时,会出现一条警告消息.

如何删除/禁止/忽略这些警告消息?

php warnings error-reporting

206
推荐指数
10
解决办法
50万
查看次数

解决LNK4098:defaultlib'MSVCRT'与.冲突

这个警告:

LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts
  with use of other libs; use /NODEFAULTLIB:library
Run Code Online (Sandbox Code Playgroud)

在Visual Studio中是一个相当常见的警告.我想了解它的确切原因以及正确的方法(如果有的话)来处理它.

这出现在一个编译的调试版本中/MDd.该项目与windows之类的东西相关联,Version.dllpdh.dll与之相关MSVCRT.dll.显然,我没有这些的调试版本,无法编译它们.

所以我添加/NODEFAULTLIB:MSVCRT到链接器命令行,它实际上删除了警告.但这实际上做了什么?为什么有必要?

dll linker warnings msvcrt visual-studio

198
推荐指数
5
解决办法
16万
查看次数