[英]get rid of `deprecated conversion from string constant to ‘char*’` warnings in GCC using typedefs?
I'm working on updating a very large codebase to be able to use gcc4.3 and ran into this issue. 我正在更新一个非常大的代码库,以便能够使用gcc4.3并遇到此问题。 The question has been asked several times, however I think my situation is a little unique and Haven't been able to get a good explanation out of it.
这个问题已经问了好几次了,但是我认为我的情况有点特殊,还没有得到很好的解释。
The error I get is 我得到的错误是
error: deprecated conversion from string constant to 'realchar {aka char*}'
错误:不建议从字符串常量转换为'realchar {aka char *}'
realchar refers to a typedef I have: realchar指的是我拥有的typedef:
typedef char* realchar;
public:
ClassNameIsMe(const realchar name="UsyncBndLNQueue");
changing realChar to be simply char* removes the warning. 将realChar更改为char *可以删除警告。 however shouldn't that be equivalent since it is a typedef pointing to char*?
但是那不是等效的,因为它是指向char *的typedef吗?
The problem is that const realchar name
is const pointer to char, ie it is equivalent to: 问题在于
const realchar name
是指向char的const指针,即,它等效于:
char * name const
instead of pointer to const char, which would be equivalent to: 而不是指向const char的指针,它等效于:
const char * name
So the warning is valid. 因此,警告有效。
See details here: 在这里查看详细信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.