LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   start to read the source code and have questions (https://www.linuxquestions.org/questions/linux-newbie-8/start-to-read-the-source-code-and-have-questions-274024/)

pipehappy 01-05-2005 02:51 AM

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!

Dark_Helmet 01-05-2005 03:19 AM

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.


All times are GMT -5. The time now is 10:29 AM.