我有一個C這樣的事情++擴展:Python的C++擴展編譯器警告
char* kwlist[] = {"x", "W"};
if (!PyArg_ParseTupleAndKeywords(args, kwrds, "OO", kwlist, &x, &W)) return NULL;
編譯器抱怨:
warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
什麼是擺脫此警告的最佳方式是什麼?
我想:
char const* kwlist[] = {"x", "W"};
但是失敗:
候選函數並不可行:從沒有任何已知的轉換 '爲const char [2]' 到 '字符*'
'字符常量* kwlist [] = ....' – WhozCraig
錯誤:沒有匹配的函數調用 'PyArg_ParseTupleAndKeywords' ...候選函數不可行:沒有從已知的轉換 '爲const char * [6]'到'char **' – Matyas