我不明白为什么我收到这条警告信息.
> fixed <- data.frame("Type" = character(3), "Amount" = numeric(3))
> fixed[1, ] <- c("lunch", 100)
Warning message:
In `[<-.factor`(`*tmp*`, iseq, value = "lunch") :
invalid factor level, NA generated
> fixed
Type Amount
1 <NA> 100
2 0
3 0
Run Code Online (Sandbox Code Playgroud) 我有一个项目使用log4cxx,boost等库,其头文件生成大量(重复)警告.有没有办法抑制来自库包含的警告(即#include <some-header.h>)或包含某些路径?我希望像往常一样在项目代码中使用-Wall和/或-Wextra而不会隐藏相关信息.我目前在make输出上使用grep,但我想要更好的东西.
我正在使用CGAL的库,在我的代码编译的链接阶段产生了很多这种形式的链接警告:
warning LNK4099: PDB 'vc80.pdb' was not found with 'gmp-vc80-mt-sgd.lib' or at 'vc80.pdb'; linking object as if no debug info
Run Code Online (Sandbox Code Playgroud)
如何在Visual C++/Studio 2008下关闭此特定链接器警告?
请注意,我对我正在使用的外部(CGAL)库没有任何控制权.我不能/不想进入重新编译外部库.因此,需要在我的最后修复消息.
只是在chrome中运行我的网站,令人惊讶的是它为我的每个.png图像提供了这个警告:
Resource interpreted as image but transferred with MIME type application/octet-stream.
Run Code Online (Sandbox Code Playgroud)
有人见过这个吗?
问候
通常在C下gcc
,我将从以下一组警告标志开始(从多个来源痛苦地组装):
-Wall -Wextra -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wbad-function-cast \
-Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef \
-Wnested-externs -Wcast-qual -Wshadow -Wwrite-strings -Wno-unused-parameter \
-Wfloat-equal -pedantic -ansi
Run Code Online (Sandbox Code Playgroud)
我将使用这组警告构建(至少我的调试版本)并修复我可能做的所有事情(通常是一切),然后只删除标记,如果它们不相关或不可修复(几乎从不这样).有时,-Werror
如果我必须在编译时离开,我也会添加.
我只是拿起C++(是的,我落后了15年),我想从右脚开始.
我的问题是:是否有人为C++预先编译了类似的完整警告标志集g++
?(我知道其中很多都是一样的.)
自升级到最新的Xcode 3.2.1和Snow Leopard以来,我一直在收到警告
"格式不是字符串文字,没有格式参数"
来自以下代码:
NSError *error = nil;
if (![self.managedObjectContext save:&error])
{
NSLog([NSString stringWithFormat:@"%@ %@, %@",
errorMsgFormat,
error,
[error userInfo]]);
}
Run Code Online (Sandbox Code Playgroud)
如果errorMsgFormat
是NSString
格式说明符(例如"print me like this: %@"
:),上面的NSLog
调用有什么问题?什么是修复它的建议方法,以便不生成警告?
如果我malloc
在我的代码中使用:
int *x = malloc(sizeof(int));
Run Code Online (Sandbox Code Playgroud)
我收到以下警告gcc
:
new.c:7: warning: implicit declaration of function ‘malloc’
new.c:7: warning: incompatible implicit declaration of built-in function ‘malloc’
Run Code Online (Sandbox Code Playgroud) 有没有办法用visual studio禁用cpp文件中的单个警告线?
例如,如果我捕获异常并且不处理它,则会收到错误4101(未引用的局部变量).有没有办法在该函数中忽略它,否则在编译单元中报告它?此刻,我放在#pragma warning (disable : 4101)
文件的顶部,但显然只是将它关闭整个单元.
我遇到了一个问题:我正在运行一个循环来处理多个文件.我的矩阵是巨大的,因此如果我不小心,我经常会失去记忆.
如果创建了任何警告,有没有办法摆脱循环?它只是继续运行循环并报告它失败了很久......令人讨厌.任何想法哦明智的stackoverflow-ers ?!