Thread: Is it okay to remove preprocessor #ifs in linux header?

  1. #1
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266

    Is it okay to remove preprocessor #ifs in linux header?

    for one reason or another, part of the arp header fields were excluded using a "#if 0" statement... I went in and changed the 0 to a 1 so I could compile my program. Do you guys see anything wrong with doing this?

    Specifically, I'm talking about the "#if 0" thats in "net/if_arp.h" which excludes some members of the arp header structure. I understand that if the code is distributed to someone else I'd have to have them remove that as well. Anything else wrong with doing this? I've read that It's used as sorta a shortcut to comment out large blocks of code. Maybe I'll start doing this too. I like it.

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    No, you shouldn't modify this header, or any other system header file for that matter.

    Jim

  3. #3
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    Quote Originally Posted by jimblumberg View Post
    No, you shouldn't modify this header, or any other system header file for that matter.

    Jim
    Then what do you recommend? Cause that's definitely what I have done. I could define this header myself I suppose.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Generally, no, unless you actually understand why those were "commented out". A somewhat safer solution might be to copy them into a header of your own, so your change to the header won't affect code that does not belong to you.

    Quote Originally Posted by Syscal
    I've read that It's used as sorta a shortcut to comment out large blocks of code. Maybe I'll start doing this too. I like it.
    Yes.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 58
    Last Post: 01-31-2011, 02:45 AM
  2. How do I completely remove Linux?
    By cpjust in forum Tech Board
    Replies: 18
    Last Post: 04-21-2010, 10:56 AM
  3. Linux header question
    By invisibleghost in forum Linux Programming
    Replies: 5
    Last Post: 02-17-2005, 10:03 AM
  4. command line alias remove for linux
    By iain in forum Tech Board
    Replies: 6
    Last Post: 11-22-2004, 01:39 PM
  5. Linux Remove Dir
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 04-20-2002, 07:44 PM