Are preprocessors necessary?

This is a discussion on Are preprocessors necessary? within the C++ Programming forums, part of the General Programming Boards category; Is there any situation where using a preprocessor is absolutely necessary? and are they considered bad practice (like void main) ...

  1. #1
    Back after 2 years Panopticon's Avatar
    Join Date
    Dec 2002
    Posts
    262

    Are preprocessors necessary?

    Is there any situation where using a preprocessor is absolutely necessary?
    and are they considered bad practice (like void main) to implement?
    I AM WINNER!!!1!111oneoneomne

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Is there any situation where using a preprocessor is absolutely necessary?
    I don't know of any other way to create inclusion guards, so yes.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    copy and paste the file to include!!! how efficient... lol

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>copy and paste the file to include!!!
    >>how efficient... lol
    Totally inefficient.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >>copy and paste the file to include!!!
    >>how efficient... lol
    >Totally inefficient.
    Totally stupid too.

    -Prelude
    My best code is written with the delete key.

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    btw, it was sarcasm..

  7. #7
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >btw, it was sarcasm..
    We know, but the urge to make a witty retort is often too much.

    -Prelude
    My best code is written with the delete key.

  8. #8
    Funniest man in this seat minesweeper's Avatar
    Join Date
    Mar 2002
    Posts
    801
    >>I don't know of any other way to create inclusion guards, so yes.<<

    Prelude, I know this is probably clear as day to you but, for the rest of us, what on earth is creating inclusion guards?

    [code]
    #include <windows.h>
    [\code]

    Is this it?

  9. #9
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >what on earth is creating inclusion guards?
    Inclusion guards make sure that a header file cannot be included more than once, even if the source asks for it.
    Code:
    #ifndef SOME_WIERD_NAME_
    #define SOME_WIERD_NAME_
    
    // Do header type stuff
    
    #endif
    -Prelude
    My best code is written with the delete key.

  10. #10
    Registered User
    Join Date
    Aug 2001
    Posts
    403
    and make sure if you use Prelude's you spell weird wrong both times

    (i before e, except after C and where it changes with no reason, like in weird)

  11. #11
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >and make sure if you use Prelude's you spell weird wrong both times
    Yes, that's the key to making it work. I wood hav menchuned it urlier but I thot it wuz obveus.

    (On a totally unrelated note, you can be more productive with copy paste...except when you make a boo-boo. )

    -Prelude
    My best code is written with the delete key.

  12. #12
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    I always just remember that "weird" is spelled weird.

    bah, english blows.

  13. #13
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    You can output gcc -E foo.c to a file so that there
    are no #'s. Then you can compile that---it's much better
    than cut and paste.

  14. #14
    Back after 2 years Panopticon's Avatar
    Join Date
    Dec 2002
    Posts
    262
    aiight thanx... especially for the english lesson. I needed that
    I AM WINNER!!!1!111oneoneomne

  15. #15
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    ~

    Preprocessors are needed for inclusion guards as said but they're also just a nice thing to have.

    Now I know just about every C++ programmer other than me disagrees, but I like to use #definitions instead of constants and macros instead of inline functions.

    A lot of people consider macros deprecated things, so I guess they'll be a day when the C++ doesn't support them anymore..

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Header file multiple inclusion question
    By Loctan in forum C++ Programming
    Replies: 16
    Last Post: 05-04-2008, 09:25 PM

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