LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 05-14-2012, 11:02 PM   #1
jayadhanesh
Member
 
Registered: Feb 2009
Location: Bangalore
Posts: 61

Rep: Reputation: 15
Header file inclusion


I have huge C code base. There is a header file which is included in multiple C files. How do I know where is the header file included for the first time?
 
Old 05-15-2012, 01:00 AM   #2
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,838

Rep: Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287
it has no meaning, it depends on the target you want to create. But you can remove/rename that include file and the first error message complaining about it is the answer.
 
Old 05-15-2012, 08:38 AM   #3
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,382

Rep: Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109Reputation: 1109
Some languages "know" whether or not a particular header file is included; others do not.

In many "C" header files you will therefore see this: (e.g. in the imaginary file, xyzzy.h):
Code:
#ifndef HEADER_XYZZY_INCLUDED
   #define HEADER_XYZZY_INCLUDED
   ... included stuff goes here ...
#endif
Notice that, if the symbol is not yet defined, the block will be included, and within that block the symbol (which is arbitrarily but consistently named, and which serves no other purpose...) is defined. Thereafter, no matter how many subsequent times we may see #include "xyzzy.h", and even though the file will be included each time, its contents will be effectively ignored in every case but the first.

It is a cumbersome mechanism, and this why other languages provide a require or use construct (your keyword may vary...) with a more powerful semantics.

Last edited by sundialsvcs; 05-15-2012 at 08:40 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with inclusion of qt header files namus123 Linux - Desktop 3 06-04-2010 03:06 PM
problem with inclusion of qt header files namus123 Linux - Mobile 2 06-04-2010 05:34 AM
automatic header inclusion rajorshi Programming 2 11-02-2003 02:29 PM


All times are GMT -5. The time now is 10:00 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration