博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
deprecated conversion from string constant to 'char*''
阅读量:4504 次
发布时间:2019-06-08

本文共 840 字,大约阅读时间需要 2 分钟。

最近在把SDL封装起来 好为以后写代码轻松些.

出现了这个错误.英文翻译大概是:不可以把字符串常量变成char*指针.

char *title= "test";

SDLWindow* window = new SDLWindow(title,400,500,400,500,SDL_WINDOW_SHOWN);

 

修改后:

char title[] = "test";

SDLWindow* window = new SDLWindow(title,400,500,400,500,SDL_WINDOW_SHOWN);

 

就可以运行了.

stackoverflow大牛回答:

If a function takes a char const *, it guarantees that it only reads whatever data the pointer points to. However, if it takes a non-const pointer, like char *, it might write to it.

As it is not legal to write to a string literal, the compiler will issue a warning.

The best solution is to change the function to accept char const * rather than char *.

 

最好的方法是修改函数参数 把char * 改成 char const * . 我还晕着...

http://stackoverflow.com/questions/7415326/deprecated-conversion-from-string-constant-to-char-error

转载于:https://www.cnblogs.com/xiaozhu520/p/6431199.html

你可能感兴趣的文章
动态规划~~矩阵链乘法
查看>>
Leetcode N-Queens II
查看>>
CodeForces 721C Journey(拓扑排序+DP)
查看>>
【概率论】3-7:多变量分布(Multivariate Distributions Part I)
查看>>
常用PY库
查看>>
排序 之 堆排序 归并排序
查看>>
linux查看修改线程默认栈空间大小(ulimit -s)
查看>>
BZOJ 1477 青蛙的约会 【扩展欧几里得】
查看>>
用phpexcelreader将excel文件读入到mysql中(转载)
查看>>
As3 Socket高低位
查看>>
15. 三数之和
查看>>
使用angular.js获取form表单中的信息
查看>>
TestNG
查看>>
高精——模板
查看>>
生成CFree 5.0 注册码
查看>>
磁力链接
查看>>
【问题解决方案】之 关于某江加密视频swf专用播放器仍无法播放的问题
查看>>
2014,码农梦想,先从态度开始!
查看>>
常用板子
查看>>
linux中安装eclipse--CnetOS6.5
查看>>