任务单 #45481

savegame2.c still has variables named 'string'

开放日期: 2022-08-27 19:42 最后更新: 2022-09-05 11:43

报告人:
属主:
类型:
状态:
关闭
组件:
里程碑:
优先:
5 - Medium
严重性:
5 - Medium
处理结果:
Fixed
文件:
3

Details

We've supposed to not use 'string' as a variable name even in C-code, to make sure we don't have problems with C++. savegame2.c still seems to use such variables.

任务单历史 (3/10 Histories)

2022-08-27 19:42 Updated by: cazfi
  • New Ticket "savagame2.c still has variables named 'string'" created
2022-08-27 19:51 Updated by: cazfi
  • Summary Updated
2022-08-27 20:35 Updated by: cazfi
  • 属主 Update from (无) to cazfi
  • 处理结果 Update from to Accepted
2022-08-27 23:43 Updated by: None
评论

We've supposed to not use 'string' as a variable name even in C-code, to make sure we don't have problems with C++.

How is that even a problem? "string" is in no way a C++ keyword, "std::string" is in a namespace, and local variables can shadow types. The issues with C++ compatibility arise when using "new", "delete", or other keywords as variable or function names.

2022-08-28 00:29 Updated by: cazfi
评论

Reply To (Anonymous)

We've supposed to not use 'string' as a variable name even in C-code, to make sure we don't have problems with C++.

"std::string" is in a namespace

Yea, it's unlikely that there's problems in any modern setup, but back in the days when it was customary for everyone to be "using namespace std" in whatever system header we faced problems with variables named 'string' (maybe as late as when we introduced Qt-client, but certainly back when we were using C++ based tolua fork)

2022-08-28 04:57 Updated by: cazfi
评论

Should note that his *reduces* diff between savegame3.c and savegame2.c (that diff was the reason I noticed this, as the same patch did not apply to both). Even if we completely ignore C++ aspect, I think this is still worth pushing in, for easing efforts to fix issues in savegame?.c modules (there's quite a many open ones at the moment)

2022-09-05 11:43 Updated by: cazfi
  • 状态 Update from 开启 to 关闭
  • 处理结果 Update from Accepted to Fixed

编辑

Please login to add comment to this ticket » 登录名