LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-05-2005, 02:51 AM   #1
pipehappy
LQ Newbie
 
Registered: Jan 2005
Posts: 9

Rep: Reputation: 0
start to read the source code and have questions


Hi
I just start to read the linux source and find there are some macro definition such as __GNUC__, where is it defined? It seems that it is not defined in the source code tree.
Thanks!
 
Old 01-05-2005, 03:19 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Here is a useful command when searching source code trees for specific text:
Code:
grep -lr "<text>" *
Replace <text> with whatever you're looking for. It will display the filenames of every file containing that text, and it will check files in all subdirectories.

As for your specific question: it may not be defined in the code tree at all. You can pass arguments to the compiler on the command line that define macros. For instance:
Code:
gcc -DMY_MACRO my_prog.c
That will cause the C preprocessor to act as though MY_MACRO was #define'd. By allowing users to add those definitions at compile-time, the developers let the user select pieces of the code that are/aren't fit for their system. Otherwise support for everything would be included and users would have to include tons of arguments to turn things on/off. Using the used-#define method saves space for the binary and speeds up the binary's execution because unnecessary code has been removed.
 
  


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
How to convert Assembly code to "C" source code ssg14j Programming 2 08-01-2005 01:48 PM
some questions encounted during reading the source code qqrilxk Linux - Security 1 12-08-2004 10:23 PM
source code for read() function ? Mike Davies Linux - Software 1 11-03-2004 03:10 PM
code to read block from the file suchi_s Programming 5 09-08-2004 07:21 AM
Questions about how to read OS source code hegel Programming 1 10-28-2003 01:18 AM


All times are GMT -5. The time now is 09:30 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration