compiler error not formatting output

This is a discussion on compiler error not formatting output within the Linux Programming forums, part of the Platform Specific Boards category; Hey all, Just have a simple question. I am not much of a programmer, more of a script guy, but ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    16

    compiler error not formatting output

    Hey all,

    Just have a simple question. I am not much of a programmer, more of a script guy, but I have a client that is getting some weird output with errors while compiling.

    Here is the output he is getting:
    Code:
    g++ test_string.cc -o test_string
    test_string.cc: In function „: <--- Notice no additional information on error
    test_string.cc:10: error: „ was not declared in this scope <--- Notice no additional information on error
    And should be getting something like:
    Code:
    g++ test_string.cc -o test_string
    test_string.cc: In function main: <---- Information presented
    test_string.cc:10: error: mystringx was not declared in this scope <---- Information presented
    Here is the code he is trying to compile. Keep in mind, this is purposely wrong to show the error output.
    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main(int argC, char* argV[])
    {
    
           string mystring = "Hello World\n";
           cout << mystringx << endl;
    }
    His Lang setting are all correct:
    Code:
    LANG=en_US.UTF-8
    LC_CTYPE="en_US.UTF-8"
    LC_NUMERIC="en_US.UTF-8"
    LC_TIME="en_US.UTF-8"
    LC_COLLATE="en_US.UTF-8"
    LC_MONETARY="en_US.UTF-8"
    LC_MESSAGES="en_US.UTF-8"
    LC_PAPER="en_US.UTF-8"
    LC_NAME="en_US.UTF-8"
    LC_ADDRESS="en_US.UTF-8"
    LC_TELEPHONE="en_US.UTF-8"
    LC_MEASUREMENT="en_US.UTF-8"
    LC_IDENTIFICATION="en_US.UTF-8"
    LC_ALL=
    My customer is running RHEL 5.4 64bit.

    Any ideas why this is formatting this way?

    Thanks!
    Joe
    Last edited by Joeg1484; 04-04-2011 at 11:55 AM.

  2. #2
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,657
    Does he need to set his terminal to use UTF-8 encoding?

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    16
    Thanks for replying rags_to_riches,

    I had him check his terminal emulation and have yet to hear back from him, however, I did test this on one of my systems and all it did was mangle the single quotes around the error description, but still printed it.

    This issue is omitting the description of the error completely.

    For reference, this is what it does with the incorrect emulation mode:

    Code:
    g++ test.cc
    test.cc: In function ‚int main(int, char**)‚:
    test.cc:7: error: ‚mystringx‚ was not declared in this scope
    It still prints the error information but mangles the quotes around it.

    Thanks!
    Joe
    Last edited by Joeg1484; 04-04-2011 at 02:30 PM.

  4. #4
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Aside from the obvious text encoding problems, you assigned the string "Hello World\n" to the string variable mystring, and you sent the string mystringx to cout, which doesn't exist.
    Quote Originally Posted by The Jargon File
    Microsoft Windows - A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

  5. #5
    Registered User
    Join Date
    Dec 2009
    Posts
    16
    Quote Originally Posted by Babkockdood View Post
    Aside from the obvious text encoding problems, you assigned the string "Hello World\n" to the string variable mystring, and you sent the string mystringx to cout, which doesn't exist.
    Yes, I understand that there are errors with the code, but there are deeper issues with the compiler; this is why we wanted to have errors in the code.

    As a refresh:
    This is what the compiler is spitting out (Incorrectly formatted)
    Code:
    g++ test_string.cc -o test_string
    test_string.cc: In function : <--- Notice no additional information on error. Missing the `In function main' part.
    test_string.cc:10: error:  was not declared in this scope <--- Notice no additional information on error. The „ should have been mystringx.
    It should look like this(Correctly formatted):
    Code:
    g++ test_string.cc -o test_string
    test_string.cc: In function main: <---- Information presented
    test_string.cc:10: error: mystringx was not declared in this scope <---- Information presented
    Thanks for the reply!

    Joe
    Last edited by Joeg1484; 04-04-2011 at 04:26 PM.

  6. #6
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Joeg1484 View Post
    I had him check his terminal emulation and have yet to hear back from him, however, I did test this on one of my systems all it did was mangle the single quotes around the error description [...] with the incorrect emulation mode
    Sure, but which incorrect emulation mode? If these are not the same, they could produce different results. It is common for inappropriate escape codes to end up in output once the terminal is screwed up, meaning all kinds of weird things can happen.
    Last edited by MK27; 04-05-2011 at 06:45 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  7. #7
    Registered User
    Join Date
    Dec 2009
    Posts
    16
    Quote Originally Posted by MK27 View Post
    Sure, but which incorrect emulation mode? If these are not the same, they could produce different results. It is common for inappropriate escape codes to end up in output once the terminal is screwed up, meaning all kinds of weird things can happen.
    Ok, you are correct about the emulation mode. They were able to get into the server via the iLo and it worked as intended.

    So, I will have them double check the emulation modes and make sure they are set properly.

    Thanks so much for the help!

    Joe

  8. #8
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Quote Originally Posted by Joeg1484 View Post
    Yes, I understand that there are errors with the code, but there are deeper issues with the compiler; this is why we wanted to have errors in the code.
    Ah yes, how absent-minded of me.
    Quote Originally Posted by The Jargon File
    Microsoft Windows - A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

  9. #9
    Registered User
    Join Date
    Dec 2009
    Posts
    16
    Quote Originally Posted by Babkockdood View Post
    Ah yes, how absent-minded of me.
    Yes, I read that again and it did seem a bit "Snippy". My apologies for that; it was not my intention to insult anyone!

    Joe

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 06:10 PM
  2. Output formatting
    By genjiguy in forum C++ Programming
    Replies: 6
    Last Post: 05-19-2005, 04:13 PM
  3. Formatting output
    By BigAl75 in forum C++ Programming
    Replies: 7
    Last Post: 05-12-2004, 08:43 AM
  4. Output formatting
    By Beginner2002 in forum C Programming
    Replies: 3
    Last Post: 09-05-2002, 07:59 PM
  5. formatting output
    By spliff in forum C Programming
    Replies: 2
    Last Post: 08-14-2001, 07:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21