更喜欢 Windows 或 Unix 代码行结尾?

发布于 2024-09-19 02:04:30 字数 178 浏览 3 评论 0原文

我编写的代码应该在 Windows 和 UNIX(如 Linux)上编译和运行。我知道行结尾之间的差异,但问题是我的代码更喜欢哪个?有关系吗?我希望它保持一致 - 假设我的所有代码仅使用 LF,还是仅使用 CRLF 更好?有比较的标准吗?

如果最重要的话我关心 C++ 和 Python 代码

I writing code that should compiled and run on both Windows and unix like Linux. I know about difference between line endings, but question is which to prefer for my code? Does it matter? I want it to be consistent - say all my code uses LF only, or is it better CRLF only? Are there critaria for comparing?

If it matters mostly I care for C++ and Python codes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

放我走吧 2024-09-26 02:04:30

使用足够智能的版本控制系统,可以在签入时忽略行结尾,并在签出时使用平台的正确值。

Use a version control system that's smart enough to ignore line-endings on check-in, and use the correct value for the platform on check-out.

写给空气的情书 2024-09-26 02:04:30

对于代码本身来说,这并不重要。所有相当现代的编辑器和编译器都可以很好地处理两者(我假设您没有使用记事本:-))。只需使用主开发平台的行尾即可。

For the code itself, it does not matter. All reasonably modern editors and compilers handle both just as well (I presume you are not using notepad :-) ). Just use the line ending of the main development platform.

青朷 2024-09-26 02:04:30

IME 最简单的方法是使用 *NIX 行结尾。 Windows 的编译器和 IDE 可以很好地处理它,并且它是 *NIX 工具的本机。使用 DOS 行结尾会给 *NIX 上的某些(甚至更流行的)文本编辑器带来不便(即使不是问题)。你经常会在行尾得到丑陋的“^M”,然后你必须显式转换或告诉你的编辑器它有 DOS 行结尾。

IME the easiest is to use *NIX line endings. Windows' compilers and IDEs can deal with it fine and it is native for *NIX tools. Using DOS line endings creates, if not problems, inconveniences with some (even the more popular) text editors on *NIX. You often get ugly '^M' at the end of the line then and you have to explicitly convert or tell your editor it has DOS line endings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文