Reputation: 17292
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
Upvotes: 4
Views: 2182
Reputation: 18268
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.
Upvotes: 2
Reputation: 283911
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.
Upvotes: 10
Reputation: 13190
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.
Upvotes: 2