Thread: Flood of errors when include .h

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    7

    Question Flood of errors when include .h

    using g++ on Solaris9

    gcc version 2.95.3 20010315 (release)

    trying to include a header file, this is actually the header file for OTL version 4, and then I get a flood of error messages from including the header. I stripped the C++ program so it is just a bare bones main with a print and return. The program compiles fine without the header file, but as soon as the header file the following are some of the errors I get :

    /usr/include/otlv4.h:6357: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6358: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6359: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6360: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6362: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6363: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6364: template argument 1 is invalid
    /usr/include/otlv4.h:6364: template argument 2 is invalid
    /usr/include/otlv4.h:6364: template argument 3 is invalid
    /usr/include/otlv4.h:6364: template argument 4 is invalid
    /usr/include/otlv4.h:6364: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6368: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6370: no matching function for call to `check_buf ()'
    /usr/include/otlv4.h:6374: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6375: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6378: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6378: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6379: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6379: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6379: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6387: template argument 1 is invalid
    /usr/include/otlv4.h:6387: template argument 2 is invalid
    /usr/include/otlv4.h:6387: template argument 3 is invalid
    /usr/include/otlv4.h:6389: invalid use of `this' in non-member function
    /usr/include/otlv4.h:6392: invalid use of `this' in non-member function
    /usr/include/otlv4.h: At top level:
    /usr/include/otlv4.h:6397: parse error before `}'
    /usr/include/otlv4.h:6404: template with C linkage
    /usr/include/otlv4.h:6727: syntax error before `&'
    /usr/include/otlv4.h:6732: ANSI C++ forbids initialization of member `null_fetch
    ed'
    /usr/include/otlv4.h:6732: making `null_fetched' static
    /usr/include/otlv4.h:6732: ANSI C++ forbids in-class initialization of non-const
    static member `null_fetched'
    /usr/include/otlv4.h:6732: declaration of `int otl_tmpl_inout_stream<TExceptionS
    truct,TConnectStruct,TCursorStruct,TVariableStruct ,TTimestampStruct>::null_fetch
    ed'
    /usr/include/otlv4.h:6415: conflicts with previous declaration `int otl_tmpl_ino
    ut_stream<TExceptionStruct,TConnectStruct,TCursorS truct,TVariableStruct,TTimesta
    mpStruct>::null_fetched'
    /usr/include/otlv4.h: In method `otl_tmpl_inout_stream<TExceptionStruct,TConnect
    Struct,TCursorStruct,TVariableStruct,TTimestampStr uct>:tl_tmpl_inout_stream(sh
    ort int, const char *, otl_tmpl_connect<TExceptionStruct,TConnectStruct,T CursorS
    truct> &, bool = false)':
    /usr/include/otlv4.h:6439: non-template type `otl_tmpl_out_stream' used as a tem
    plate
    /usr/include/otlv4.h:6439: confused by earlier errors, bailing out


    Any suggestions would be greatly appreciated.

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    7
    Here is code for the program that genereated the above errors :

    Code:
    #include <iostream.h>
    #include <stdio.h>
     
    //
    #define OTL_ORA8 // Compile OTL 4.0/OCI8
    //
    #include <otlv4.h> // include the OTL 4.0 header file
     
    //otl_connect db;  // connect object
     
     
    int main ()
    {
      cout << "Hello World!\n";
       return 0;
    }

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    170
    "this" is a c++ feature.

    You said you were compiling this a stright c, maybe you need to be compiling as c++?
    Best Regards,

    Bonkey

  4. #4
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    yeah, cout is an instance of a class and << is an overloaded left The code in iostream.h is c++ not c. That's why you get the errors.

  5. #5
    Registered User
    Join Date
    Dec 2002
    Posts
    7
    Maybe there's a misunderstanding, but
    g++ compiles both C and C++ code.

    If I remove the #include <otlv4.h> and
    #define OTL_ORA8 from the above code, it compiles fine.

    There is nothing wrong with having
    <iostream.h> and cout << in the code.

    As an example, the following code compiles :

    Code:
    #include <iostream.h>
    #include <stdio.h>
     
     
     
    int main ()
    {
      cout << "Hello World!\n";
       return 0;
    }

  6. #6
    Originally posted by erik2004
    Maybe there's a misunderstanding, but
    g++ compiles both C and C++ code.

    If I remove the #include <otlv4.h> and
    #define OTL_ORA8 from the above code, it compiles fine.

    There is nothing wrong with having
    <iostream.h> and cout << in the code.

    As an example, the following code compiles :

    Code:
    #include <iostream.h>
    #include <stdio.h>
     
     
     
    int main ()
    {
      cout << "Hello World!\n";
       return 0;
    }
    well why use it then if it doesn't work???
    anywayz why did you place it there in the first place??
    Dev C++
    Win XP/2k/98

    I DO NOT TAKE CLASSES I DONT GET HOMEWORK THIS IS NOT A HOMEWORK QUESTION!!!

    He's lean he's keen... He's the spank machine!

  7. #7
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    erik2004, could you post otlv4.h. I could better help you if I could see the contents of that header.

  8. #8
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Okay, I was just doing some searching online and it looks like you may need to also do this:

    Code:
    #define OTL_ORA8_PROC
    After you define OTL_ORA8.

  9. #9
    Registered User
    Join Date
    Dec 2002
    Posts
    7
    I'm trying to find the problem that's causing the error.

    I want to use the code because there's a lot of features offered in the header file <otlv4.h>

    The code compiles fine without the header, but as soon as I include the header file <otlv4.h>, the code generates the errors posted in the first post.

    Supposedly, it is possible to compile code with the header. I'd like to find out why I can't.

    I am looking to see if anyone can spot the problem or has run across a similar situation where they know what the fix might be or even if they might have some bits of information that might help solve the problem. I looking to tap into the collective programming knowledge of the world to try to solve a problem.

  10. #10
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Just post the header file. I don't have that file, so I can't say what needs to be done to get it to compile.

  11. #11
    Registered User
    Join Date
    Dec 2002
    Posts
    7
    otlv4.h is about ~400k.

    Let me find out how to transfer or post the code so you can look at it.

    I've attached a .zip file to this post.

  12. #12
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    That header is one big bastard. Not to fret though, it looks like you need to uncomment line 43.

  13. #13
    Registered User
    Join Date
    Dec 2002
    Posts
    7
    I uncommented line 43 as well as other lines and still have the same error messages.

  14. #14
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I'm at a loss here. I'm not seeing any problems. If you want I can try to compile it. I will get errors too but if it compiles correctly I should only get "undefined reference" errors rather than syntax errors. But I don't have many of the all the headers this file uses... The best solution would be for you to make sure that your oci.h function is accurate and up to date. As much as I usually flame people who post questions more than once I would re-post this question with a title that makes mension of the header so that someone who is has done this before may help you. I'm not even running the same OS

  15. #15
    Registered User
    Join Date
    Dec 2002
    Posts
    7
    Okay. Thanks very much for all your help and suggestions!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. precompiled header file
    By George2 in forum C++ Programming
    Replies: 20
    Last Post: 04-07-2008, 08:14 AM
  2. Problem while constructing IP packet and sending using socket() system call
    By cavestine in forum Networking/Device Communication
    Replies: 10
    Last Post: 10-15-2007, 05:49 AM
  3. does not name a type ERROR
    By DarrenY in forum C++ Programming
    Replies: 3
    Last Post: 10-13-2007, 04:54 AM
  4. Sneaky little linker errors...
    By Tozar in forum C++ Programming
    Replies: 8
    Last Post: 10-25-2006, 05:40 AM
  5. dont konw what to do next.
    By negevy in forum C Programming
    Replies: 29
    Last Post: 09-09-2005, 03:06 PM