Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1043087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:36:39+00:00 2026-05-16T15:36:39+00:00

Reverse engineering code and I’m kind of appalled at the style, but I wanted

  • 0

Reverse engineering code and I’m kind of appalled at the style, but I wanted to make sure there’s no good reason for doing these things….

Is it just me or is this a horrible coding style

if ( pwbuf ) sprintf(username,"%s",pwbuf->pw_name);
else sprintf(username,"%d",user_id);

And why wrap code not intended for compilation in an

#if 0
....
#endif

Instead of comments?


EDIT: So as some explained below, this is due to the possibility to flummox /* */ which I didn’t realize.

But I still don’t understand, why not just use your programming environment tools or favorite text editor’s macro’s to block comment it out using “//”

wouldn’t this be MUCH more straightforward and easy to know to visually skip?


Am I just inexperienced in C and missing why these things might be a good idea — or is there no excuse, and I’m justified in feeling irritated at how ugly this code is?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:36:40+00:00Added an answer on May 16, 2026 at 3:36 pm

    #if 0 is used pretty frequently when the removed block contains block-comments

    I won’t say it’s a good practice, but I see it rather often.

    The single line flow-control+statement is easy enough to understand, although I personally avoid it (and most of the coding guidelines I’ve worked under forbid it)

    BTW, I’d probably edit the title to be somewhat useful “Why use #if 0 instead of block comments”

    If you have the following

    #if 0
            silly();
            if(foo)
               bar();
            /* baz is a flumuxiation */
            baz = fib+3;
    #endif
    

    If you naively replace the #if 0/#endif with /* */, that will cause the comment to end right after flumuxiation, causing a syntax error when you hit the */ in the place of the #endif above..

    EDIT: One final note, often the #if 0 syntax is just used while developing, particularly if you have to support multiple versions or dependencies or hardware platforms. It’s not unusual for the code to be modified to

    #ifdef _COMPILED_WITHOUT_FEATURE_BAZ_
        much_code();
    #endif
    

    With a centralized header defining (or not) hundreds of those #define constants. It’s not the prettiest thing in the world, but every time I’ve worked on a decent sized project, we’ve used some combination of runtime switches, compile-time constants (this), compile-time compilation decisions (just use different .cpp’s depending on the version), and the occasional template solution. It all depends on the details.

    While you’re the developer just getting the thing working in the first place, though… #if 0 is pretty common if you’re not sure if the old code still has value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can you say me if there are good tools for reverse-engineering my C# applications.
Possible Duplicate: Protect .NET code from reverse engineering? I want to make my software
Possible Duplicate: Protect .NET code from reverse engineering? we just develop a application with
Is it possible to configure Hibernate reverse engineering and code generation tool in such
I am reverse engineering some Java code into a class diagram. Now I'm wondering
I have some auto-generated hibernate DAO code which was generated by Eclipse-hibernate reverse engineering
I've been contemplating how to protect my C/C++ code from disassembly and reverse engineering.
After reverse engineering code first, I got entity classes and mapping. Most of the
How well can modern JavaScript obfuscation/minification tools protect my code from reverse engineering? Also,
Reverse engineering source code into a VS 2010 UML class model? I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.