Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

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

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.
Old 01-05-2005, 03:19 AM   #2
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Here is a useful command when searching source code trees for specific text:
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:
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.


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 > Forums > Linux Forums > Linux - Newbie

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

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