如下的代码:

#include <stdio.h>

#include <string>

#include <algorithm>

#include <cassert>

#include <cctype>

#include <boost/algorithm/string.hpp>

int main(int argc, char *argv[])

{

char song[17] = "Book of Taliesyn";

boost::to_upper(song);

assert(std::string(song) == "BOOK OF TALIESYN");

return 0;

}

编译的时候报错:

Error      1              error C4996: 'std::_Transform1': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' c:\program files (x86)\microsoft visual studio 12.0\vc\include\algorithm           1026       1              Test13

[分析]

  1. 搜索到如下的文章:

https://stackoverflow.com/questions/903064/compiler-error-function-call-with-parameters-that-may-be-unsafe

The warning is telling you that you risk a buffer overflow if n is too large -- which you know can't happen because of the way you just computed with a min, but the poor commpiler doesn't. I suggest you take the compiler's own advice and use -D_SCL_SECURE_NO_WARNINGS for this one source file...

  1. 关于如何修复: https://stackoverflow.com/questions/25046829/what-does-use-d-scl-secure-no-warnings-mean

-D is a command line compiler flag which causes the rest of the text to be treated as if there was a #define in your code.

In solution explorer, right click the project, select "properties". The project property page will open. Expand the ">C/C++" entry in the tree on the left and select "Preprocessor" under that. The top entry in the right pane should be "Preprocessor Definitions". In that edit box, add _SCL_SECURE_NO_WARNINGS, separating it from the other entries with a ;

[解决]

加上这个宏定义后,就编译通过了.

Compiler Error: Function call with parameters that may be unsafe的更多相关文章

  1. VS2013编译程序出现error C4996: 'std::_Fill_n': Function call with parameters that may be unsafe

    最近按照BiliBil网站Visual C++网络项目实战视频教程,使用VS2013编写一个基于MFC的对话框程序HttpSourceViewer,采用了WinHttp库.Boost xpressiv ...

  2. error C4996: Function call with parameters that may be unsafe – this call relies on the caller to ch

    在加入QCustomplot时有如题的错误 1>c:\program files (x86)\microsoft visual studio11.0\vc\include\xutility(21 ...

  3. error C4996: Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct

    使用VS13 跟  google protocbuf时出现了这个问题:真蛋疼,用别人的东西你就说不安全,用你自己的东西时你怎么不说不安全来着! 解决方案 在protoc   生成的头文件中加上 #pr ...

  4. windows下编译caffe出现错误 C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe?

    解决方案来自http://blog.csdn.net/u012556077/article/details/50353818

  5. Alignment And Compiler Error C2719 字节对齐和编译错误C2719

    Compiler Error C2719 'parameter': formal parameter with __declspec(align('#')) won't be aligned The ...

  6. 转:ORA-15186: ASMLIB error function = [asm_open], error = [1], 2009-05-24 13:57:38

    转:ORA-15186: ASMLIB error function = [asm_open], error = [1], 2009-05-24 13:57:38http://space.itpub. ...

  7. idea报错:error java compilation failed internal java compiler error

    idea下面报如下问题 error java compilation failed internal java compiler error 解决办法:Setting->Compiler-> ...

  8. c++ builder 2010 错误 F1004 Internal compiler error at 0x9740d99 with base 0x9

    今天遇到一个奇怪的问题,拷贝项目后,在修改,会出现F1004 Internal compiler error at 0x9740d99 with base 0x9 ,不管怎么改,删除改动,都没用,关闭 ...

  9. Compiler Error Message: CS0016: Could not write to output file 回绝访问

    Compiler Error Message: CS0016: Could not write to output file 'c:\Windows...dll' 拒绝访问 C:\Windows\Te ...

随机推荐

  1. springmvc+ajax——第一讲(搭建)

    下面是整个整合测试的代码: ajax01.html TestController web.xml springmvc.xml applicationContext.xml <!DOCTYPE h ...

  2. P1118 [USACO06FEB]数字三角形`Backward Digit Su`… 回溯法

    有这么一个游戏: 写出一个11至NN的排列a_iai​,然后每次将相邻两个数相加,构成新的序列,再对新序列进行这样的操作,显然每次构成的序列都比上一次的序列长度少11,直到只剩下一个数字位置.下面是一 ...

  3. Git submodule 仓库中包含另外的仓库(子仓库)

    Git submodule 仓库中包含另外的仓库(子仓库) 添加 submodule 在父仓库 git 目录下: git submodule add ssh://ip/[path]/xxx.git 注 ...

  4. JS获取验证码后倒计时不受刷新及关闭影响

    HTML部分 <input type="button" id="code_btn" value="获取验证码"> JS部分 // ...

  5. 20172328《程序设计与数据结构》实验四 Android程序设计报告

    20172328<程序设计与数据结构>实验四 Android程序设计报告 课程:<程序设计与数据结构> 班级: 1723 姓名: 李馨雨 学号:20172328 实验教师:王志 ...

  6. linux学习笔记 apache php mysql +linux

    1 #yum remove httpd 2 #yum -y install httpd php-common php-devel php-gd php-mcrypt php-mbstring php- ...

  7. 洛谷P1880 石子合并(区间DP)(环形DP)

    To 洛谷.1880 石子合并 题目描述 在一个园形操场的四周摆放N堆石子,现要将石子有次序地合并成一堆.规定每次只能选相邻的2堆合并成新的一堆,并将新的一堆的石子数,记为该次合并的得分. 试设计出1 ...

  8. Java笔记(十)堆与优先级队列

    优先级队列 一.PriorityQueue PriorityQueue是优先级队列,它实现了Queue接口,它的队列长度 没有限制,与一般队列的区别是,它有优先级概念,每个元素都有优先 级,队头的元素 ...

  9. Python中的iteritems()和items()

    我用的是Python3.6 在Python3.x中,iteritems() 和 viewitems() 这两个方法都已经废除了,用 items()替换iteritems() ,for循环来遍历出来.

  10. LeetCode(15. 三数之和)

    问题描述 给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组. 注意:答案中不可以包含重复 ...