warning:deprecated conversion from string constant to 'char *'
warning:deprecated conversion from string constant to ‘char *’ 解决方式
#include <iostream>
using namespace std;
int fuc(char *a)
{
cout << a << endl;
}
int main()
{
fuc("hello");
}
Linux 环境下当GCC版本号比較高时,编译代码可能出现的问题。
主要原因是:
char * 指针指向的字符串是同意改动的,将其作为形參。意味着在函数的某处代码可能改动其指向字符串。
而理论上,我们传给函数的字面常量是没法被改动的。
解决方法1.
把函数形參 參数类型改动为const char *。
解决方法2.
假设肯定函数中不会对形參指向变量进行改变。
能够用(char *)
进行强制转换。
warning:deprecated conversion from string constant to 'char *'的更多相关文章
- warning:deprecated conversion from string constant to 'char *' 解决方案
#include <iostream> using namespace std; int fuc(char *a) { cout << a << endl; } i ...
- warning: deprecated conversion from string constant to 'char*
warning: deprecated conversion from string constant to 'char* #include<iostream> using namespa ...
- deprecated conversion from string constant to ‘char*’
deprecated conversion from string constant to ‘char*’ #include <iostream> using namespace std; ...
- 排错:expected unqualified-id before string constant
一个低级但是不好定位的编译错误,常见的问题是: 1. 语句的 { 括号不匹配. 2. 缺少 : , 特别是类的定义或声明,枚举的定义. 3. 变量名或函数名使用了保留字.
- c++ 中double与string之间的转换,char *
运行代码为 /* * main.cpp * * Created on: Apr 7, 2016 * Author: lizhen */ #include <iostream> //#inc ...
- warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
在C++中, char* p = "abc"; // valid in C, invalid in C++ 会跳出警告:warning: ISO C++ forbids conve ...
- warning: ISO C++ forbids converting a string constant to 'char*'
第1种字符串赋值方式: char * fileName="./2017-09-02-10-34-10.xml";//这一种字符串赋值方式已经被ISO禁止了 第2种字符串赋值方式: ...
- expected declaration specifiers or '...' before string constant
/work/platform_bus_dev_drv/led_dev.c:52: error: expected declaration specifiers or '...' before stri ...
- leetcode:ZigZag Conversion 曲线转换
Question: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of ...
随机推荐
- luogu2618 数字工程 DP
题目大意:ACM实验室开启了一个数字工程项目,希望把正整数n通过一些特殊方法变成1.可采用的方法有:(1)减去1:(2)除以它的任意一个素因子. 每操作一次消耗一个单位的能量.问,把n变成1最少需要消 ...
- 在Spring Boot中使用Spring-data-jpa实现分页查询
转自:https://www.cnblogs.com/sandea/p/8275890.html 在我们平时的工作中,查询列表在我们的系统中基本随处可见,那么我们如何使用jpa进行多条件查询以及查询列 ...
- 部署微信定位精灵APK到Genymotion
- 基于Spring boot的web项目搭建教程(一)
前言: 本教程参考了大量前辈的代码,在此不方便一一列举.本教程使用IDEA开发工具搭建项目,对于本人的IDEA已经集成了某些插件,比如Lombok,Thymeleaf,yml等插件,这些插件不在文中提 ...
- LVS十种调度算法介绍
1.轮叫调度(Round Robin)(简称rr) 轮叫调度(Round Robin Scheduling)算法就是以轮叫的方式依次将请求调度不同的服务器,即每次调度执行i = (i + 1) mod ...
- BZOJ 2140 Tarjan
思路: 跟POJ有一道时限挺长的题一模一样 哦 POJ 1904 题解可以看这个(捂脸) http://blog.csdn.net/qq_31785871/article/details/52963 ...
- 关于原生app、webApp、混合app的介绍
WebApp 原生App(Native App) 混合App(hybrid App) webApp: 用html5,css3 js开发的网页,运行在移动端的浏览器 zepto.angular.vue. ...
- hdu3488 / hdu3435 / hdu1853 最小费用最大流 圈 拆点
题目大意: 在一个有向图中,求经过所有点的最小圈. 思路: (如果是用二分图的完美匹配来做,那么直接上模版就好了).http://www.cnblogs.com/Potato-lover/p/3991 ...
- 单元测试工具 unitils
Unitils模块组件 Unitils通过模块化的方式来组织各个功能模块,采用类似于Spring的模块划分方式,如unitils-core.unitils-database.unitils-mock等 ...
- Eigen库对齐问题:declspec(align('16')) 的形参将不被对齐
一:错误提示:error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned 英文提示:erro ...