Thread: What is Preprocessor...?

  1. #1
    Registered User
    Join Date
    Apr 2003

    What is Preprocessor...?

    In C or C++ when we write a code in the editor "our source code" ,it is transfer to


    and then


    and then


    Please can u explain what is the purpose of preprocessor ,what is its functionality ??? what does it do with the source code ??? its mechanism etc etc ???
    Thanks in advance

  2. #2
    Join Date
    Nov 2002
    I might be wrong because I haven't really done any extensive research into how the preprocessor works, but I think it's basically a text editor that recognizes certain characters. Like so it knows when it sees #define NUMBER 10 to replace every instance of NUMBER with 10.
    And yea the order is.
    Then its compiled to an object file
    Then its linked with other object files
    Then its in executable form.

    There is a command in gcc that lets you see the source code after it goes through the preprocessor I think, ive never tryed it though.

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Its the preprocessors job to prepare the translation unit for the compiler. This generally means taking out bits of code between #ifs and expanding #define macros. Also doing the #including etc.
    Any c/c++ keyword that starts with a # is a preprocessor instruction.
    look up in your helpfiles...
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :-

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C/C++ preprocessor directives
    By coletek in forum C++ Programming
    Replies: 11
    Last Post: 01-11-2009, 04:24 PM
  2. Writing an HTML Preprocessor
    By thetinman in forum C++ Programming
    Replies: 1
    Last Post: 09-17-2007, 08:01 AM
  3. Preprocessor Directives Problem
    By MipZhaP in forum C++ Programming
    Replies: 6
    Last Post: 02-18-2005, 01:53 PM
  4. Preprocessor string pasting fun
    By ggambett in forum C Programming
    Replies: 6
    Last Post: 11-11-2004, 06:40 PM
  5. Preprocessor Functions
    By mart_man00 in forum C Programming
    Replies: 2
    Last Post: 01-09-2003, 09:58 PM