Results 1 to 3 of 3

Thread: Checking to see if a file has already been included

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    183
    any idea of there is a way to check to see if a file has already been included.
    I have two C files that both share a header file and it seems silly to #include <studio.h> in both.
    Any ideas?

  2. #2
    Lively Member
    Join Date
    May 2000
    Posts
    123
    you can just put the #include <stdio.h> in the header file that they both share.

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You may have noticed that all (properly-written!) header files have something like:
    Code:
    #ifndef __HEADER_H__ // replace with mangled filename
    #define __HEADER_H__
    
    /* code here */
    
    #endif
    This works, at the header level, to prevent them being included twice. Just go right ahead and include anything you want in any file
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width