add #if guard around fUseUPnP to fix build warning #213

pull dholbert wants to merge 2 commits into bitcoin:master from dholbert:master changing 1 files +1 −3
  1. dholbert commented at 5:48 PM on May 9, 2011: contributor

    This fixes the build problem that I described in #212

    (NOTE: There's actually one other un-#if-guarded usage of the variable "fUseUPnP" in this file, but that one doesn't seem to cause build problems, for whatever reason. So I just added #if guards around this usage, to make the change as minimal as possible.)

  2. Add #ifdef USE_UPNP around usage of fUseUPnP to fix build failure. 685ef99a05
  3. jgarzik commented at 5:49 PM on May 9, 2011: contributor

    This is not correct. The point of fUseUPnP is that it should always evaluate to false if upnp is absent. That puts the #ifdef in a single location, rather than requiring an ifdef at every site, crapping up the code.

  4. dholbert commented at 5:54 PM on May 9, 2011: contributor

    ah -- perhaps ths change should actually be "#ifdef", not "#if"?

    It looks like fUseUPnP is only defined if USE_UPNP is defined -- quoting main.cpp:

    <pre> #ifdef USE_UPNP #if USE_UPNP int fUseUPnP = true; #else int fUseUPnP = false; #endif #endif </pre>

    ...though it's declared unconditionally in main.h:

    <pre> extern int fUseUPnP; </pre>

    Maybe "fUseUPnP" should be defined & set to false in main.cpp, if USE_UPNP isn't defined?

  5. TheBlueMatt commented at 6:12 PM on May 9, 2011: member

    Probably should be, though it doesn't cause issues unless you have stale outputs in obj/*

  6. Define fUseUPnP (and set it to false) even if USE_UPNP is undefined. 78e7ced921
  7. dholbert commented at 6:30 PM on May 9, 2011: contributor

    OK, this latest commit reverts my original changes, and instead groups the "USE_UPNP undefined" situation in with "USE_UPNP=0" situation, for defining fUseUPnP.

    Probably should be, though it doesn't cause issues unless you have stale outputs in obj/*

    It actually did cause issues for me, the first time I ever built bitcoin.

  8. TheBlueMatt commented at 6:47 PM on May 9, 2011: member

    What compiler version? The only ones I've ever seen don't cause problems there. Did you not start to compile with USE_UPNP=0/1 then stop and go back and compile with USE_UPNP=

  9. dholbert commented at 7:22 PM on May 9, 2011: contributor

    Did you not start to compile with USE_UPNP=0/1 then stop and go back and compile with USE_UPNP=

    Sorry, yeah -- you're totally right. I thought I was building from scratch, but I think what happened was:

    • I initially built using stock bitcoin source (no makefile tweaks)
    • That failed since I don't have the UPNP library.
    • Then I tweaked makefile.unix to have "USE_UPNP:="
    • ...and that gave me the error described in issue #212.

    So this indeed only seems to be an issue when you build with stale object files in /obj. Still, I think the above series of steps are probably not uncommon, among people who lack the upnp library, so I think it's a build use-case that's worth being concerned about. :)

  10. TheBlueMatt commented at 7:46 PM on May 9, 2011: member

    Well, it doesn't matter that much as the autotools stuff should fix all this.

  11. jgarzik commented at 9:24 PM on May 12, 2011: contributor

    Can someone roll these into a single commit, please? It is ready to pull, otherwise.

    We prefer not to pull in situations where we're pulling "commit A, now commit B fixes commit A" type situations, to avoid cluttering the upstream bitcoin git history.

  12. dholbert commented at 9:34 PM on May 12, 2011: contributor

    I can do that, sure - should I just do that as a fresh commit & fresh pull request, then? (sorry, I'm new to github)

  13. TheBlueMatt commented at 9:35 PM on May 12, 2011: member

    Did it for you :), fUseUPnPfix branch, ACK.

  14. dholbert commented at 9:35 PM on May 12, 2011: contributor

    ah, thanks! :)

  15. jgarzik commented at 9:42 PM on May 12, 2011: contributor

    pulled bluematt's fix

  16. jgarzik closed this on May 12, 2011

  17. sipa referenced this in commit 9d09322b41 on Mar 27, 2015
  18. zathras-crypto referenced this in commit 8081ffec6b on Sep 1, 2015
  19. TheBlueMatt referenced this in commit 582b2934e6 on Oct 20, 2015
  20. deadalnix referenced this in commit 7b2fc1cac6 on Jan 19, 2017
  21. deadalnix referenced this in commit 3df8e66f0b on Jan 20, 2017
  22. classesjack referenced this in commit 2c15f54789 on Jan 2, 2018
  23. attilaaf referenced this in commit b16bf81b77 on Jan 13, 2020
  24. MarcoFalke referenced this in commit 09bc7bfed1 on Feb 25, 2021
  25. rajarshimaitra referenced this in commit 8aac9f57c5 on Aug 5, 2021
  26. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 21:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me