How to get carriage return AND linefeed in CW?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get carriage return AND linefeed in CW?

1,284 Views
chuckcorley
NXP Employee
NXP Employee

I've always had to edit format specifiers from \n to \n\r when importing code into CodeWarrior projects.  It's painful but tolerable.  Now I'm trying to work in C++ and the tradition cout << " ...."  << endl; is only generating the newline (\n); I'm not moving back to the start of line.  I don't want to change all endl entries to "\n\r" just to use CodeWarrior.  Is there a tool setting that makes \n equivalent to \n\r?  A search of the help system reveals a compiler option to swap \n and \r but I really need them both; on other platforms \n accomplishes both.

Labels (1)
0 Kudos
2 Replies

697 Views
CrasyCat
Specialist III

Hello

I am a bit confused here.

According to my experience, text file generated on Linux or Solaris Hosts can be displayed without any trouble in CodeWarrior editor.

So I am not sure of the issue you are currently facing.

If you are looking for a way to convert End-of-line characters on files that appears inside of the CodeWarrior project view, you can proceed as follows:

  • Select the file name in the CodeWarrior Project view
  • Select File > Convert  Line Delimiters to and select the appropriate end-of-line format.

If you are looking for a way to change the end of line character used when you are writing to a file then you need to look into the C++ library. As far as I know for QorIQ Processor CodeWarrior uses the GNU libraries.

It might be a good idea to check whether GNU is providing some help to achieve that.

I hope this helps a bit.

CrasyCat

0 Kudos

697 Views
chuckcorley
NXP Employee
NXP Employee

This program in Codewarrior:


#include <stdio.h>

int main()

{

     printf("Hello World \r\n");

     printf("Hello World \r\n");

     printf("Hello World \n");

     printf("Hello World \n");

}

Produces:

Hello World

Hello World

Hello World

                 Hello World

The same program compiled with gcc and run on a PC produces:

Hello World

Hello World

Hello World

Hello World

Hence my comment that I have always had to convert \n to \r\n to move code from some other environment to CodeWarrior.

Changing the line delimiters is not the problem.

0 Kudos