Thread: Problems with include?

  1. #1
    Registered User
    Join Date
    Feb 2008
    Location
    N?A
    Posts
    23

    Problems with include?

    if i have 2 header files and in the first file i use the second
    and in the second i use the first?
    but it's not allowed

    how to solve that??


    Thank's

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Look up inclusion guards.

  3. #3
    Registered User
    Join Date
    Jan 2007
    Location
    Euless, TX
    Posts
    144
    The "easiest" solution is to remove the "other" header from the "main" header file. Or if you would rather, do this:
    At the top of each header file do this for each one --
    #ifndef SOME_HEADER_H (this would be your header file's name)
    #define SOME_HEADER_H
    .
    .
    .
    .
    #endif

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by kcpilot View Post
    At the top of each header file do this for each one --
    #ifndef SOME_HEADER_H (this would be your header file's name)
    #define SOME_HEADER_H
    .
    .
    .
    .
    #endif
    That's called inclusion guards.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C programing doubt
    By sivasankari in forum C Programming
    Replies: 2
    Last Post: 04-29-2008, 09:19 AM
  2. some problems with #include
    By Cmaniac in forum C Programming
    Replies: 6
    Last Post: 04-15-2007, 11:28 PM
  3. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04:25 AM
  4. #Include "class" problems
    By Unregistered in forum C++ Programming
    Replies: 17
    Last Post: 11-26-2001, 10:40 AM