Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Why #if 0 ... #endif

Why #if 0 ... #endif

Scheduled Pinned Locked Moved C / C++ / MFC
sysadmin
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    What would be a purpose of enclosing a block of code with #if 0 ... #endif

    //#if 0
    qDebug() << "Discovered service on"
    << serviceInfo.device().name() << serviceInfo.device().address().toString();
    qDebug() << "\tService name:" << serviceInfo.serviceName();
    qDebug() << "\tDescription:"
    << serviceInfo.attribute(QBluetoothServiceInfo::ServiceDescription).toString();
    qDebug() << "\tProvider:"
    << serviceInfo.attribute(QBluetoothServiceInfo::ServiceProvider).toString();
    qDebug() << "\tL2CAP protocol service multiplexer:"
    << serviceInfo.protocolServiceMultiplexer();
    qDebug() << "\tRFCOMM server channel:" << serviceInfo.serverChannel();
    //#endif

    Mircea NeacsuM 1 Reply Last reply
    0
    • L Lost User

      What would be a purpose of enclosing a block of code with #if 0 ... #endif

      //#if 0
      qDebug() << "Discovered service on"
      << serviceInfo.device().name() << serviceInfo.device().address().toString();
      qDebug() << "\tService name:" << serviceInfo.serviceName();
      qDebug() << "\tDescription:"
      << serviceInfo.attribute(QBluetoothServiceInfo::ServiceDescription).toString();
      qDebug() << "\tProvider:"
      << serviceInfo.attribute(QBluetoothServiceInfo::ServiceProvider).toString();
      qDebug() << "\tL2CAP protocol service multiplexer:"
      << serviceInfo.protocolServiceMultiplexer();
      qDebug() << "\tRFCOMM server channel:" << serviceInfo.serverChannel();
      //#endif

      Mircea NeacsuM Offline
      Mircea NeacsuM Offline
      Mircea Neacsu
      wrote on last edited by
      #2

      It's a way of commenting out a block of code. In your case, seems like a way to eliminate some debug messages.

      Mircea

      L 1 Reply Last reply
      0
      • Mircea NeacsuM Mircea Neacsu

        It's a way of commenting out a block of code. In your case, seems like a way to eliminate some debug messages.

        Mircea

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        BUT does #if 0 evaluates to "true " ? I have been using #ifdef BYPASS #endif where BYPASS is not defined to skip the enclosed block

        CPalliniC 1 Reply Last reply
        0
        • L Lost User

          BUT does #if 0 evaluates to "true " ? I have been using #ifdef BYPASS #endif where BYPASS is not defined to skip the enclosed block

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          Quote:

          BUT does #if 0 evaluates to "true " ?

          0 evaluates to 'false' see, for instance, the bottom line of this page: If (The C Preprocessor)[^]

          Quote:

          I have been using #ifdef BYPASS #endif where BYPASS is not defined to skip the enclosed block

          The compiler skips the code if BYPASS is not defined (that is, the 'condition' is 'false').

          "In testa che avete, Signor di Ceprano?" -- Rigoletto

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups