Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 c++ 创建一个 iphone 测试,并且我想使用 nslog(显示调试信息的唯一方法?)每当我想包含 nslog 函数时,我的 cpp 必须更改为 mm 对吗?这是唯一的方法吗?因为我不想在移动到其他平台时改回 cpp。
感谢帮助
由于 NSLog 仅存在于 Objective-C 平台上,为什么不在LogMessage()一个调用 NSLog 的单个 .mm 文件中创建您自己的方法,采用标准 C++ 参数,并从通常命名的 C++ 文件中调用它。这样你就不需要重命名每个需要记录到 .mm 的文件
LogMessage()
在其他平台上,只需包含另一个实现,LogMessage()因为无论如何都没有 NSLog 可以调用。