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 9190747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:31:59+00:00 2026-06-17T20:31:59+00:00

I’m using a complicated C code that includes many, many compilation options. This makes

  • 0

I’m using a complicated C code that includes many, many compilation options. This
makes the code very hard to read. I’d like to produce a copy of the code reflecting
the way it’s actually compiled. I’ve gotten pretty good results using the “unifdef”
utility, which I didn’t know about until recently. However, I’m puzzled why it’s so hard
to invoke, and am wondering if I’m missing something.

Consider this example:

#ifdef A
  printf("A\n");
#endif
#ifdef B
  printf("B\n");
#endif

If you invoke unifdef with “unifdef -DA junk.c”, you get:

  printf("A\n");
#ifdef B
  printf("B\n");
#endif

Because you didn’t tell unifdef that B was undefined, it didn’t take it out.

I would like the utility to behave such that when I say unifdef -DA, I get instead:

  printf("A\n");

This would correspond to what the C preprocessor is actually doing:
whatever branches are undefined are omitted.

To get this behavior with unifdef, I seem to need to use
“unifdef -DA -UB junk.c”, explicitly telling it that B is undefined.
Though maybe I missed a simpler way to invoke it.

I wrote a python script to generate the long list of required -D and -U
flags from the Makefile of the code I’m using (typically 80 per routine).
And the results are excellent. But I’m wondering whether such a script
is actually necessary.

It’s also possible that another utility (sunifdef? coan?) has my desired behavior
built in already; if so, please mention it.

  • 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-06-17T20:32:00+00:00Added an answer on June 17, 2026 at 8:32 pm

    The coan utility does what you need with the -m flag:

    $ coan source -DA -m test.c 
      printf("A\n");
    

    From the man page:

    -m, --implicit
        Assume that any symbol that is not --define-ed is implicitly
        --undef-ed.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am using JSon response to parse title,date content and thumbnail images and place

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.