mega compile errors for small program

This is a discussion on mega compile errors for small program within the C++ Programming forums, part of the General Programming Boards category; Hi guys, there is something really strange going on with an assignment due by midnight!! I have read archives, advice ...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    16

    Angry mega compile errors for small program

    Hi guys, there is something really strange going on with an assignment due by midnight!!
    I have read archives, advice etc and can't relate it to what I am doing.

    I have to write a library and implementation file and then a program that includes these.

    The library is ok I think, and so is the implementation file which I have compiled to .o (prob wrong terminology but not much of a clue for this stuff.)

    My driver file is called quadraticDriver.cpp yet when I attempt to compile it (g++ -c quadraticDriver.cpp) there are some really strange errors.


    So here are some of them, I will be watching for the postings and any ideas would really be appreciated!!



    QuadraticDriver.cpp:1: error: syntax error before `/' token
    In file included from /usr/include/c++/3.3.2/i386-redhat-linux/bits/c++locale.h
    42,
    from /usr/include/c++/3.3.2/iosfwd:46,
    from /usr/include/c++/3.3.2/ios:44,
    from /usr/include/c++/3.3.2/ostream:45,
    from /usr/include/c++/3.3.2/iostream:45,
    from QuadraticDriver.cpp:3:
    /usr/include/langinfo.h:48: error: `__LC_TIME' was not declared in this scope
    /usr/include/langinfo.h:48: error: enumerator value for `ABDAY_1' not integer
    constant
    /usr/include/langinfo.h:241: error: `__LC_COLLATE' was not declared in this
    scope
    /usr/include/langinfo.h:241: error: enumerator value for `_NL_COLLATE_NRULES'
    not integer constant
    /usr/include/langinfo.h:265: error: `__LC_CTYPE' was not declared in this scope
    /usr/include/langinfo.h:265: error: enumerator value for `_NL_CTYPE_CLASS' not
    integer constant
    /usr/include/langinfo.h:356: error: `__LC_MONETARY' was not declared in this
    scope
    /usr/include/langinfo.h:356: error: enumerator value for `__INT_CURR_SYMBOL'
    not integer constant
    /usr/include/langinfo.h:470: error: `__LC_NUMERIC' was not declared in this
    scope
    /usr/include/langinfo.h:470: error: enumerator value for `__DECIMAL_POINT' not
    integer constant
    /usr/include/langinfo.h:491: error: `__LC_MESSAGES' was not declared in this
    scope
    /usr/include/langinfo.h:491: error: enumerator value for `__YESEXPR' not
    integer constant
    /usr/include/langinfo.h:506: error: `__LC_PAPER' was not declared in this scope
    /usr/include/langinfo.h:506: error: enumerator value for `_NL_PAPER_HEIGHT' not
    integer constant
    /usr/include/langinfo.h:511: error: `__LC_NAME' was not declared in this scope
    /usr/include/langinfo.h:511: error: enumerator value for `_NL_NAME_NAME_FMT'
    not integer constant
    /usr/include/langinfo.h:520: error: `__LC_ADDRESS' was not declared in this
    scope
    /usr/include/langinfo.h:520: error: enumerator value for `
    _NL_ADDRESS_POSTAL_FMT' not integer constant
    /usr/include/langinfo.h:535: error: `__LC_TELEPHONE' was not declared in this
    scope
    /usr/include/langinfo.h:535: error: enumerator value for `
    _NL_TELEPHONE_TEL_INT_FMT' not integer constant
    /usr/include/langinfo.h:542: error: `__LC_MEASUREMENT' was not declared in this
    scope
    /usr/include/langinfo.h:542: error: enumerator value for `
    _NL_MEASUREMENT_MEASUREMENT' not integer constant
    /usr/include/langinfo.h:546: error: `__LC_IDENTIFICATION' was not declared in
    this scope
    /usr/include/langinfo.h:546: error: enumerator value for `
    _NL_IDENTIFICATION_TITLE' not integer constant
    QuadraticDriver.cpp: In function `int main()':
    QuadraticDriver.cpp:13: error: `cout' undeclared (first use this function)
    QuadraticDriver.cpp:13: error: (Each undeclared identifier is reported only
    once for each function it appears in.)
    QuadraticDriver.cpp:27: error: `cin' undeclared (first use this function)
    QuadraticDriver.cpp:31: error: syntax error before `,' token

  2. #2
    Registered User
    Join Date
    Oct 2004
    Posts
    32
    We need to see the code.

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Hi,

    It looks like all those errors are due to faulty "include's". The last errors are telling:

    QuadraticDriver.cpp: In function `int main()':
    QuadraticDriver.cpp:13: error: `cout' undeclared (first use this function)
    QuadraticDriver.cpp:13: error: (Each undeclared identifier is reported only
    once for each function it appears in.)
    QuadraticDriver.cpp:27: error: `cin' undeclared (first use this function)
    QuadraticDriver.cpp:31: error: syntax error before `,' token
    You have to have lines like this at the top of any file that uses cout<< or cin>>:
    Code:
    #include <iostream>
    using namespace std;
    as well as includes for files that define enumerations.

    QuadraticDriver.cpp:1: error: syntax error before `/' token
    Maybe a faulty comment in one of your files? Only one slash instead of two?

    /usr/include/langinfo.h:48: error: enumerator value for `ABDAY_1' not integer
    constant
    An error in your enumerator definition? Or, maybe you assigned one of your enum variables a word not in the definition list. Here is an example:

    enum Car {truck, sedan, sportscar};

    A variable of type Car can only be assigned the values 'truck', 'sedan', and 'sportscar'.
    Last edited by 7stud; 04-28-2005 at 12:11 AM.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    > there is something really strange going on with an assignment due by midnight!!
    Email yourself a message to a week ago, when we could have actually helped you to solve your problem.
    Or try www.cprogramming-miracles.com
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Lightbulb My general advice for beginners:

    Welcome s_UNI_,

    Well it's too late now (after midnight) but maybe this will help with your next assignment.

    Here's the big secret to sucessful programming:
    Don't write the whole freekin' program before compiling and running! It is very difficult to debug a program with multiple errors.


    - Start-out with a "Hello World" type of program.
    - Add a one or two lines of code.
    - Test-compile and test-run.
    - Debug as required.

    - Add one or two more lines of code, etc.

    Note that you can't just type-in your program in line-number sequence, test-compiling as you go. You have to figure-out the best development sequence for test-compiling and test-running as you go along... This is part of the fun of programming!

    It is also helpful to add some extra cout statements so you can "see" what's going on before the program is completed. You can remove them or comment them out once your program is debugged.

    This may seem silly, but it will greatly reduce your frustration-level! And, experienced programmers do the same thing (with larger chunks of code, of course).

    Compilers are easily confused. They know there is an error, but they don't know what you are trying to do. Sometimes one real error can cause the compiler to report hundreds of errors! If you test-compile every few lines, at least you know where to look for the error.

    When the compiler reports errors, the first actual error is usually near the reported line-number. After that, the reported errors may just be effects of the first error.

    Linker errors (you had lots of 'em) are harder to track down. Mainly, because there are no line numbers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program giving errors
    By andy bee in forum C Programming
    Replies: 5
    Last Post: 08-11-2010, 10:38 PM
  2. Compile Errors in my Code. Can anyone help?
    By DGLaurynP in forum C Programming
    Replies: 1
    Last Post: 10-06-2008, 09:36 AM
  3. Compile errors in stl header files
    By Swordsalot in forum C++ Programming
    Replies: 2
    Last Post: 07-20-2008, 02:41 AM
  4. C program compile but not doing the calculations
    By abs.emailverify in forum C Programming
    Replies: 8
    Last Post: 11-08-2006, 07:43 AM
  5. Using a makefile to compile a program using SDL
    By Noerbo in forum Game Programming
    Replies: 9
    Last Post: 04-30-2006, 09:11 AM

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