views:

156

answers:

3

What does 'inconsistent line ending' mean in Visual Studio 2010?

I also see this error in a dialog when I'm coding in VS2010. How can I stop this error from showing in the dialog?

+3  A: 

Windows, Unix, and older Mac OSs use different line endings. (Newer MacOS uses the Unix convention).

Windows uses CR/LF, Unix uses only LF.

Visual Studio is telling you it found messed up line endings on your file, indicating it was probably edited on different operating systems, and has fixed them all for you to be consistent. If you're getting that message more than once per file, then you have to stop whatever is causing the line endings to get borked in the first place, which is most likely not Visual Studio but some other editor.

Billy ONeal
What would be nice would be a 'don't bug me about this' option, maybe a registry hack...
Chris Huang-Leaver
@Chris: Why would you want it to not tell you? Either unix or windows line endings are fine. Mixing them in the same file is just stupid.
Billy ONeal
Different line endings in the same file, no that's a real problem! I was talking about when one file in another teams project has different line endings, it's really annoying having to do a full rebuild just for that. Of course we both know what the real answer to that is ;-)
Chris Huang-Leaver
@Chris: That's not what the OP is talking about. The "Inconsistent Line Endings" dialog box is shown only when a single file has differing line endings.
Billy ONeal
@Chris: You can disable such checking under Tools -> Options, and then navigating to Environment\Documents. There is a checkbox for "Check for inconsistent line endings on load".
Billy ONeal
A: 

Microsoft's response from (http://connect.microsoft.com/VisualStudio/feedback/details/538108/inconsistent-line-endings-dialogue-in-ide):

"What that usually means is that you have lines ending with something other than a carriage return/line feed pair. It often happens when you copy and paste from a web page into the code editor.

Since you're developing in Visual Studio, you'll obviously want to choose "Windows" from the drop down."

Sean James
my problem is when i open the file he show the error. i know the problem but how i can stop him for a long time then i work comfortably
4thpage
A: 

Billy and Sean has already described the cause of the problem, however one potential fix is to set up your version control system to enforce the correct line endings for .h and .cpp files. For instance if you're using Subversion then this is a matter of setting the svn:eol-style property to native. You can also do File -> Advanced Save Options to force the EOL style for each file you have problems with.

the_mandrill