Circular #includes

This is a discussion on Circular #includes within the C++ Programming forums, part of the General Programming Boards category; I have lots of .h files that i need to #include to each other. Nothing i can do keeps dev ...

  1. #1
    Rebooted Inquirer's Avatar
    Join Date
    Apr 2002
    Posts
    281

    Question Circular #includes

    I have lots of .h files that i need to #include to each other. Nothing i can do keeps dev from giving me wierd errors that repeat, and it seems that it gets the errors because it recursively keeps including itself. I am trying to use inclusion protection, but i think i am doing it wrong. Let me know if you have any insight, or if i need to post code. Thanks for your time.
    Compilers:
    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    Others:
    MinGW on XP

  2. #2
    Registered User quagsire's Avatar
    Join Date
    Jun 2002
    Posts
    60
    Code:
    #ifndef _MY_HEADERFILE_1_H_
    #define _MY_HEADERFILE_1_H_
    // put all the stuff here 
    #endif
    Code:
    #ifndef _MY_HEADERFILE_2_H_
    #define _MY_HEADERFILE_2_H_
    // put all the stuff here 
    #endif
    etc.
    Just use more descriptive identifiers. I use my initials_headerfilename eg. _JN_MYMATH_H_.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. circular includes or something
    By dudeomanodude in forum C++ Programming
    Replies: 2
    Last Post: 12-11-2008, 11:38 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  3. Circular include issue
    By einarp in forum C++ Programming
    Replies: 10
    Last Post: 07-10-2006, 08:43 PM
  4. circular includes?
    By Raybdbomb in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2006, 09:40 PM
  5. Circular includes
    By ventolin in forum C++ Programming
    Replies: 2
    Last Post: 05-23-2004, 05:43 PM

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