Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Escape sequences not recognized (GCC options )
Escape sequences not recognized [message #1818618] Fri, 20 December 2019 16:22 Go to next message
Helen Keller is currently offline Helen KellerFriend
Messages: 173
Registered: June 2019
Senior Member
The attached TEST C++ code does not change cout text color while using Linux complier / liker.

It works fine when crosscompiled.

Apparently GCC tools have to be instructed to recognize escape characters , such as used in cout or printf.

The question is - where to find GCC options to change that ?


cout << "\x1B[34m" << "Hello World!\n" << "\x1B[0m";
cout << " START test area " << __LINE__ << endl;
cout << __FUNCTION__ << endl;
cout << " START test area " << __LINE__ << endl;
cout << __FUNCTION__ << endl;
perror("TEST perror ");
cout << " [\033[1;31]";
cout << setw(50) << "\033[1;31mbold red text\033[0m\n";
perror("TEST perror ");
Re: Escape sequences not recognized [message #1818632 is a reply to message #1818618] Fri, 20 December 2019 19:41 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
This seems to be an issue in the display terminal, not compiler/linker/library.

Are you using the same terminal for both runs?

Are you sure that the Linux terminal obeys the ANSI escape sequences?


--

Tauno Voipio
Re: Escape sequences not recognized [message #1818644 is a reply to message #1818632] Sat, 21 December 2019 14:21 Go to previous messageGo to next message
Helen Keller is currently offline Helen KellerFriend
Messages: 173
Registered: June 2019
Senior Member
Yes, both crosscompiled ( Run as configured for TCF ) and complied code ( Run as local C/C++ code)
runs on same terminal / console- but DIFFERENT OS !
Even tried older version of Eclipse 2019 with same results.

It looks as some OS ( compiler?) option is not set to recognize escape characters - gleaned from many internet resources.
After all - the code runs on DIFFERENT OS !
So the question is - what option and where ?


Re: Escape sequences not recognized [message #1818645 is a reply to message #1818644] Sat, 21 December 2019 16:08 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
The operating system does not care of the escape sequences. It is the terminal emulation software which does it. There are absolutely no compiler switches for the escape sequences. To verify, take assembly listings of the compiled code and have a look at the packed escape strings.

Have you run the terminals inside of an Eclipse window or as the basic Linux terminal?

You have actively avoided to state the specifics of the system, compiler versions, program used to connect to the embedded system. I guess from previous posts that your OS is Ubuntu Linux 18.04 LTS, probably with the Ubuntu desktop.


--

Tauno Voipio
Re: Escape sequences not recognized [message #1818650 is a reply to message #1818645] Sat, 21 December 2019 22:39 Go to previous messageGo to next message
Helen Keller is currently offline Helen KellerFriend
Messages: 173
Registered: June 2019
Senior Member
Have you run the terminals inside of an Eclipse window or as the basic Linux terminal?

I believe this forum is for C/C++ CDT related issues - hence why do I have to specify the above ?
It is an issue of stdio and related software - the "console" is a term used by Eclipse IDE
Let's focus on problem, not attempts to pass the issue elsewhere.

You have actively avoided to state the specifics of the system, compiler versions, program used to connect to the embedded system. I guess from previous posts that your OS is Ubuntu Linux 18.04 LTS, probably with the Ubuntu desktop.
DITTO
Let's focus on problem, not attempts to pass the issue elsewhere.

You are indirectly saying that the lack of recognition of escape codes is something of NO ISSUE in the latest version of Ubuntu.
Are you serious? So it is a problem of GCC or TCF or RPi or old version of Ubuntu or Eclipse ?
Peculiar / best guess way to troubleshoot.

I do not care WHERE is the problem, but I am used to logical analysis, not "must be fixed in the latest xyz guesses or is a fault of 3rd party software".
BTW I am looking into source code for "error" - which uses stderr "console" , writes is red color so logically should have means of switching colors.











Re: Escape sequences not recognized [message #1818652 is a reply to message #1818650] Sun, 22 December 2019 00:26 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Quote:
It is an issue of stdio and related software - the "console" is a term used by Eclipse IDE
Let's focus on problem, not attempts to pass the issue elsewhere.


Your issue has absolutely nothing to do with Eclipse, CDT or stdio.
https://en.wikipedia.org/wiki/ANSI_escape_code

Quote:
ANSI escape sequences are a standard for in-band signaling to control the cursor location, color, and other options on video text terminals and terminal emulators. ...Although hardware text terminals have become increasingly rare in the 21st century, the relevance of the ANSI standard persists because most terminal emulators interpret at least some of the ANSI escape sequences in output text.


The Linux terminal is a terminal emulator.
How the emulator responds to ANSI sequences depends on faithfulness to the terminal it is emulating.
Terminal emulation is only an Eclipse issue if you are using the Eclipse console.
The Eclipse console is a basic terminal emulator.
It does not emulate ANSI sequences for color.

Quote:

Have you run the terminals inside of an Eclipse window or as the basic Linux terminal?
I believe this forum is for C/C++ CDT related issues - hence why do I have to specify [OS and development environment] ?

Because there may be subtle differences imposed by the development environment.
Every environment has its own JVM that may or may not differ among implementations.
Knowing what you are really doing may be helpful.


[Updated on: Sun, 22 December 2019 04:16]

Report message to a moderator

Re: Escape sequences not recognized [message #1818661 is a reply to message #1818652] Sun, 22 December 2019 15:00 Go to previous messageGo to next message
Helen Keller is currently offline Helen KellerFriend
Messages: 173
Registered: June 2019
Senior Member
The Linux terminal is a terminal emulator.
How the emulator responds to ANSI sequences depends on faithfulness to the terminal it is emulating.
Terminal emulation is only an Eclipse issue if you are using the Eclipse console.

DUH!

The Eclipse console is a basic terminal emulator.
It does not emulate ANSI sequences for color.


Would you kindly explain WHY SAME terminal AKA ECLIPSE / C++ console used while running software on remote / embedded (RPi) system RECOGNIZE the escape characters , while running it on local machine fails?
I do not recall adding anything extra to remote software - just iostream to make it work.

I do realize you will ALWAYS defend Eclipse and pass the buck elsewhere, but MY OBJECTIVE is to find solution and attitude like yours is not helping.
It would be prudent to stop "defending / passing some-place else " posts.
It MAY leave you more time to enjoy other , better stuff in life.




Re: Escape sequences not recognized [message #1818669 is a reply to message #1818661] Sun, 22 December 2019 18:10 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Well, I'm not going to guess.
Asking for help is a two-way street.
You were asked above what you were using and you still refuse to answer.
Until you can actually show what you are doing, it isn't possible to say why.

I do know that the Eclipse console doesn't process ANSI color sequences.
In fact, you seem to have discovered that yourself.
Clearly, whatever you used before wasn't the Eclipse console.

As for better enjoying myself, I can simply ignore you.
Your choice.

EDIT:
In your original post, you asked what the GCC options might be.
You were told that there aren't any wrt ANSI sequence interpretation.
If there are, they don't have any connection to Eclipse/CDT but you can search for yourself.
Here is the latest list from GNU. Enjoy!
https://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html

Update:
Here's a small program:
#include <iostream>
#include <Eigen/Dense>
using namespace std;

int main() {
	cout << "!!!Hello Eigen World!!!" << endl; 
	cout << "\e[1;32;40m";
	cout << "green on black";
	cout << "\e[m";
	cout << endl;
	cout << endl << "Normal text?" << endl;
	return 0;
}


Here's the output to the Eclipse console:
index.php/fa/37014/0/

Here' the output to a Linux terminal:
index.php/fa/37015/0/

[Updated on: Sun, 22 December 2019 20:42]

Report message to a moderator

Re: Escape sequences not recognized [message #1818725 is a reply to message #1818669] Tue, 24 December 2019 15:52 Go to previous message
Helen Keller is currently offline Helen KellerFriend
Messages: 173
Registered: June 2019
Senior Member
SOLVED CASE CLOSED
Thanks for all the help from the group.
It is much appreciated.

Ask Mrs Google for "Eclipse ANSI" .
The question remains why it works without the 3rd part plug in when the app is crosscompiled.

Just in case anybody really wants to know - an interesting outcome of this (?) 3 party plug-in.
The first console output is NORMAL, no additional line feeds.
When the console is redraw it has an EXTRA line feed between ALL outputs.
I could post a screen shot if you do no believe it.

[Updated on: Tue, 24 December 2019 16:28]

Report message to a moderator

Previous Topic:Symbol 'std' could not be resolved Issue
Next Topic:Can't edit variable values when debugging
Goto Forum:
  


Current Time: Fri Apr 26 07:25:04 GMT 2024

Powered by FUDForum. Page generated in 0.03396 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top