#define Glib::string std:wstring
我有 Linux 代码,我想将其移植到 Windows。该代码使用 Glib::ustring
,但我想将所有字符串替换为 std::wstring
以便进行测试。
有没有办法将所有 Glib::string
定义为 std::wstring
而无需在代码中更改它?类似于 typedef
或 #define
的东西?
I have Linux code and I want to port it to Windows. The code uses Glib::ustring
, but I want to replace all the strings to std::wstring
for testing purposes.
Is there a way to define all Glib::string
to std::wstring
without changing it in code? Something similar to typedef
or #define
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是什么让您认为 Glib::ustring 可以与 std::wstring 互换/互操作?如果您进行了这种替换,很可能只会出现一堆编译器错误,或者如果您不幸的话,它会以不同的语义进行编译和运行。
我认为您必须硬着头皮将 Linux 代码转换为首先使用
wstring
,然后 Windows 移植应该会简单很多。也就是说,假设您在 Windows 版本中不需要 Glib,您可以删除对此的所有引用,然后在标头中创建您自己的假类型:
What makes you think that
Glib::ustring
is interchangeable/interoperable withstd::wstring
? Most likely if you made that substitution you'd just get a bunch of compiler errors, or if you're unlucky it would compile and run with different semantics.I think you're going to have to bite the bullet and convert your Linux code to use
wstring
first and then the Windows port should be a lot less complicated.That said, assuming you don't need
Glib
in the Windows version you could remove all references to that and then create your own fake type in a header: