Problems with include?

This is a discussion on Problems with include? within the C Programming forums, part of the General Programming Boards category; if i have 2 header files and in the first file i use the second and in the second i ...

  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,185
    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
    Posts
    23,024
    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, 10:19 AM
  2. some problems with #include
    By Cmaniac in forum C Programming
    Replies: 6
    Last Post: 04-16-2007, 12:28 AM
  3. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 05:25 AM
  4. #Include "class" problems
    By Unregistered in forum C++ Programming
    Replies: 17
    Last Post: 11-26-2001, 10:40 AM

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