What is Preprocessor...?

This is a discussion on What is Preprocessor...? within the C Programming forums, part of the General Programming Boards category; In C or C++ when we write a code in the editor "our source code" ,it is transfer to 1---Preprocessor ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    12

    What is Preprocessor...?

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

    1---Preprocessor

    and then

    2---Compliler

    and then

    3---Linker

    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
    Posts
    303
    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.
    Preprocesser
    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
    Posts
    2,572
    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...
    #define
    #include
    #if
    #ifdef
    #ifndef
    etc.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

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, 03: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, 12:53 PM
  4. Preprocessor string pasting fun
    By ggambett in forum C Programming
    Replies: 6
    Last Post: 11-11-2004, 05:40 PM
  5. Preprocessor Functions
    By mart_man00 in forum C Programming
    Replies: 2
    Last Post: 01-09-2003, 08:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21