I’m working through the vulkan tutorial and came across GLFW_TRUE and GLFW_FALSE. I presume there’s a good reason but in looking at the docs it’s just defining 1 and 0, so I’m sorta at a loss as to why some libraries do this (especially in cpp?).

Tangentially related is having things like vk_result which is a struct that stores an enum full of integer codes.

Wouldn’t it be easier to replace these variables with raw int codes or in the case of GLFW just 1 and 0?

Coming mostly from C, and having my caps lock bound to escape for vim, the amount of all caps variables is arduous for my admittedly short fingers.

Anyway hopefully one of you knows why libraries do this thanks!

  • Kissaki
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    6 hours ago

    Microsoft SQL Server has a bit type and you always use 0 and 1 and cast/convert them. No native bool type. It’s a hassle.

    • floofloof@lemmy.ca
      link
      fedilink
      English
      arrow-up
      2
      ·
      6 hours ago

      Well that would be ok, because any standard tool for interfacing with the database would transparently treat bit in the DB as bool in the code. I think many DBs call it a bit rather than a bool.

      • Kissaki
        link
        fedilink
        English
        arrow-up
        2
        ·
        6 hours ago

        that assumes you don’t write any SQL

        • floofloof@lemmy.ca
          link
          fedilink
          English
          arrow-up
          1
          ·
          5 hours ago

          I’m used to ORM layers where you can write SQL queries but you’re basically converting the results to objects before you use them. These kinds of things tend to handle bits OK, and bit parameters can usually be set as booleans directly. I haven’t used SQL Server in a while though so maybe it isn’t as convenient as that.