GVKun编程网logo

-Werror导致编译器在#warning上停止.我该怎么做才能防止这种情况发生?(编译出现warning)

16

如果您对-Werror导致编译器在#warning上停止.我该怎么做才能防止这种情况发生?和编译出现warning感兴趣,那么这篇文章一定是您不可错过的。我们将详细讲解-Werror导致编译器在#wa

如果您对-Werror导致编译器在#warning上停止.我该怎么做才能防止这种情况发生?编译出现warning感兴趣,那么这篇文章一定是您不可错过的。我们将详细讲解-Werror导致编译器在#warning上停止.我该怎么做才能防止这种情况发生?的各种细节,并对编译出现warning进行深入的分析,此外还有关于接受属性在拖放文件时将被忽略,如何防止这种情况?、angularjs – 我该怎么做才能获得使用UI-Grid在屏幕上显示的行、c# – 为什么在这种情况下编译器不会抱怨?、fhir.executeBundle 替换资源 ID...如何防止这种情况?的实用技巧。

本文目录一览:

-Werror导致编译器在#warning上停止.我该怎么做才能防止这种情况发生?(编译出现warning)

-Werror导致编译器在#warning上停止.我该怎么做才能防止这种情况发生?(编译出现warning)

首先,我希望它停止警告.但我也希望打印出一些信息性的消息(比如“回来实现这个!”).

不幸的是,我的编译器不支持#info,#message,#pragma message()等.

我知道有-Wno-error =< something>,但是我的google-foo很弱,我似乎无法找到< something>为#warning.我试过-Wno-error =警告,只是说“没有 – 警告”.与“警告”相同.

有什么建议?

值得一提的是,我使用的是Tensilica xtensa编译器,xt-xcc,它似乎是一个gnu派生词,或者至少使用了gnu前端.它的版本是8.0.0.

解决方法

我不熟悉Tensilica xtensa编译器(xt-xcc),但您可以使用标准 gcc
#pragma GCC diagnostic warning "-Wcpp"

使#warning成为简单警告的问题(因为-Werror而不是错误).要使效果暂时,您可以使用#pragma和#wragma GCC诊断推送和#pragma GCC诊断pop之间的#warning.

当我编译包含以下内容的文件时

#pragma GCC diagnostic push
    #pragma GCC diagnostic warning "-Wcpp"
    #warning one
    #pragma GCC diagnostic pop

    #warning two

使用-cerror使用gcc 4.6.1(命令gcc -c -Werror warning-test.c),我得到以下输出:

warning-test.c:3:2: warning: #warning one [-Wcpp]
    warning-test.c:6:2: error: #warning two [-Werror=cpp]
    cc1: all warnings being treated as errors

当我删除第二个#warning时,编译不会被错误中断.

您还可以使用-Werror -Wno-error = cpp替换-Werror编译器选项.我不知道cpp类别的警告包含哪些其他影响(并且您可能在其他某个地方有一个合法的#warning要捕获为错误),因此暂时禁用特定#warning的错误并立即恢复设置似乎更准确的方法满足您的要求.

编辑(2016):使用gcc版本4.8.4和4.9.2给出了几乎相同的行为(仅额外打印出源代码行).但是使用gcc版本5.0.1(Ubuntu 15.04中包含的预发布版本)将提供两个警告,除非包含选项-Werror = cpp.所以似乎 – 更新gcc的错误不再像以前那样暗示-Werror = cpp,如果需要它需要单独提供.

<input type =“ file”>接受属性在拖放文件时将被忽略,如何防止这种情况?

接受属性在拖放文件时将被忽略,如何防止这种情况?

您将需要执行服务器端验证,但是通过对照Set允许的类型检查文件的类型,可以使用户体验更好。

const allowedTypes = new Set(['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','application/vnd.ms-excel']);
document.querySelector('input[type=file]').addEventListener('change',function(){
  if(!allowedTypes.has(this.files[0].type)){
    console.log("Not a CSV file");
    this.value = '';//clear the input for invalid file
  } else {
    console.log("CSV file");
  }
});
<input type="file" accept=".csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel">

,

请注意,csv文件具有许多MimeType,因此您应该检查多个 "application/vnd.ms-excel" => .CSV Mimetypes,您可以在客户端进行检查 以及通过将文件类型与可接受类型的数组进行比较 这样您就可以添加或删除适合您需求的方式

// the list of the accepted types since we need it always it's better to
// make it global instead of local to the onchange litener,and even you can
// add other types dynamically as well;
const acceptedTypes = ["text/csv","text/x-csv","application/x-csv","application/csv","text/x-comma-separated-values","text/comma-separated-values","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"];
document.querySelector("[type='file']").onchange = function() {
  if(!acceptedTypes.includes(this.files[0].type)) {
    console.log("This file is not allowed for upload");
    // if the file is not allowed then clear the value of the upload element
    this.value = "";
  }
};

如果仅在用户拖放文件时希望这种行为,则可以像这样自定义

const acceptedTypes = ["text/csv","application/vnd.ms-excel"];
// global variable to hold if the user has dragged the file or not
let isDragged = false;
// the `ondragover` gets triggered before the `onchange` event so it works as expected
document.querySelector("[type='file']").ondragover = function() {
  isDragged = true;
};
document.querySelector("[type='file']").onchange = function() {
  // if there was no drag then do nothing
  if(!isDragged) return;
  if(!acceptedTypes.includes(this.files[0].type)) {
    console.log("This file is not allowed for upload");
    // if the file is not allowed then clear the value of the upload element
    this.value = "";
  }
  isDragged = false;
};
,

您只需要添加一个事件监听器和函数来接受或拒绝该文件:

fileInput.addEventListener("change",func);

var func = function() {
  if(fileInput.files[0].type == /*insert your file types here*/) {
    //accept file and do stuff with it
  } else {
    //reject and tell user that is was rejected and why
  }
}

我不确定这是否适用于拖放文件输入,但我知道它适用于常规类型。每当文件更改时,都会调用change事件。

angularjs – 我该怎么做才能获得使用UI-Grid在屏幕上显示的行

angularjs – 我该怎么做才能获得使用UI-Grid在屏幕上显示的行

我正在使用带有无限滚动的UI-Grid,我只想获取用户屏幕上显示的行,以便将它们发送到模态窗口进行编辑(根据用户的要求,他们想要做这在当前观点之外).

我怎么能实现这个目标?让我们说在一个1920×1080的屏幕上,屏幕能够显示25行,我想得到那25行显示.显然这个数字根据屏幕尺寸和/或分辨率而有所不同,所以我想根据这两个来捕获,如果没有,那么至少要分配标准25.

这有可能吗?

编辑:
我查看了rowTemplates并实现了如下角度视口:

rowTemplate: '<div ng-repeat="(colRenderIndex,col) in colContainer.renderedColumns track by col.uid" ui-grid-one-bind-id-grid="roWrenderIndex + \'-\' + col.uid + \'-cell\'"ng-role="{{col.isRowHeader ? \'rowheader\' : \'gridcell\'}}" ui-grid-cell viewport-enter="" viewport-leave=""></div>'

但是我迷失了,因为我可以用这种方法标记出可见的东西.此外,这会在行中的每个单元格中放置角度视口标记,并且在UI-Grid支持组中的一些问题中检查后,我发现我无法修改视口模板(我可以在其中添加视口属性而不是行(包括这些标签).

有任何想法吗?这是朝着正确方向迈出的一步吗?

解决方法

你有没有尝试过gridScope.renderedRows或event.targetScope.renderedRows?

方式1:

$scope.$on('ngGridEventData',function (event) {
    console.log(event.targetScope.renderedRows);
});

方式2:

var gridApi;
gridOptions = {
    //...
    onRegisterapi: function (api) {

        gridApi = api;

    }
}

//在您的代码中,您可以通过以下方式获取renderRows:

gridApi.grid.renderContainers.body.renderedRows

c# – 为什么在这种情况下编译器不会抱怨?

c# – 为什么在这种情况下编译器不会抱怨?

这是代码:

private TreeNode GetTopLevelNode(TreeNode childNode)
    {
        if (childNode == null)
            throw new ArgumentNullException("childNode","childNode is null.");

        if (childNode.Parent == null) return childNode;

        TreeNode node = childNode;
        while (true)
        {
            if (node.Parent == null)
            {
                return node;
            }
            node = node.Parent;
        }

    }

在while循环中,仅当node.Parent == null时,才会返回一个节点,

为什么编译器不报告“并非所有代码路径返回值”错误?

如果不能满足’node.Parent == null’,则不返回树节点.
编译器无法检测到这种情况?

解决方法

因为你正在使用while(true){,除了使用return之外没有其他方法可以退出循环.如果不能满足node.parent == null,那么它将是一个无限循环.因此,没有返回就无法通过循环,编译器也不会抱怨.

此外,您指定的代码几乎总是返回一个null TreeNode,这是您真正想要的吗?

编辑:我看到你解决了这个问题.

fhir.executeBundle 替换资源 ID...如何防止这种情况?

fhir.executeBundle 替换资源 ID...如何防止这种情况?

当您执行交易时,效果将与单独发布资源相同。在 POST 中,服务器 确定资源 ID。在常规 POST 中,id 只是被忽略或引发错误。在事务中,id 用于管理跨事务的引用解析,但服务器仍然选择持久资源的 id(并相应地更新所有引用)。如果要控制事务中的资源 ID 值,请使用 PUT 而不是 POST。 (请注意,并非所有服务器都允许“更新插入” - 即在特定资源位置执行创建的 PUT。)有关详细信息,请参阅 http://hl7.org/fhir/http.html#upsert。

关于-Werror导致编译器在#warning上停止.我该怎么做才能防止这种情况发生?编译出现warning的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于接受属性在拖放文件时将被忽略,如何防止这种情况?、angularjs – 我该怎么做才能获得使用UI-Grid在屏幕上显示的行、c# – 为什么在这种情况下编译器不会抱怨?、fhir.executeBundle 替换资源 ID...如何防止这种情况?等相关知识的信息别忘了在本站进行查找喔。

本文标签:

上一篇objective-c – 双击NSOutlineView的标题是否触发双击方法?(双击标题条可以完成什么操作)

下一篇emacs keybinding编译C文件(emacs如何编译)