Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. The Lounge
  4. On the indexing of arrays and other little wonders
Forum Updated to NodeBB v4.3 + New Features

On the indexing of arrays and other little wonders

Scheduled Pinned Locked Moved The Lounge
24 Posts 4 Posters 11.8k Views 3 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.
  • the_T the_

    @kshegunov said:

    @the_ said:

    public class if {
    
    } 
    

    Ouch! There's tons of weird stuff a C dev might do, like:

    I think it was Java code where i found this crap :)

    Joel BodenmannJ Offline
    Joel BodenmannJ Offline
    Joel Bodenmann
    wrote on last edited by Joel Bodenmann
    #21

    @kshegunov
    You might like my embedded graphics/GUI library then. Everything that can be done with preprocessor macros is done using preprocessor macros:

    https://bitbucket.org/Tectu/ugfx/src/fb100bcc25225cfad0bab5d40bef1db703e9670a/src/gdisp/gdisp_colors.h?at=master&fileviewer=file-view-default
    https://bitbucket.org/Tectu/ugfx/src/fb100bcc25225cfad0bab5d40bef1db703e9670a/src/gdisp/gdisp_driver.h?at=master&fileviewer=file-view-default#gdisp_driver.h-812

    If you keep browsing the sources you will find other goodies :)

    Industrial process automation software: https://simulton.com
    Embedded Graphics & GUI library: https://ugfx.io

    kshegunovK 1 Reply Last reply
    0
    • Joel BodenmannJ Joel Bodenmann

      @kshegunov
      You might like my embedded graphics/GUI library then. Everything that can be done with preprocessor macros is done using preprocessor macros:

      https://bitbucket.org/Tectu/ugfx/src/fb100bcc25225cfad0bab5d40bef1db703e9670a/src/gdisp/gdisp_colors.h?at=master&fileviewer=file-view-default
      https://bitbucket.org/Tectu/ugfx/src/fb100bcc25225cfad0bab5d40bef1db703e9670a/src/gdisp/gdisp_driver.h?at=master&fileviewer=file-view-default#gdisp_driver.h-812

      If you keep browsing the sources you will find other goodies :)

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #22

      @Joel-Bodenmann
      Right ... because my life doesn't suck enough and I would like to suffer more? I'm with @Wieland on that preprocessor magic - I avoid as the devil avoids incense ... there's a whole battery of cheat-sheets for dealing with that ugly monster ...

      Read and abide by the Qt Code of Conduct

      Joel BodenmannJ 1 Reply Last reply
      0
      • kshegunovK kshegunov

        @Joel-Bodenmann
        Right ... because my life doesn't suck enough and I would like to suffer more? I'm with @Wieland on that preprocessor magic - I avoid as the devil avoids incense ... there's a whole battery of cheat-sheets for dealing with that ugly monster ...

        Joel BodenmannJ Offline
        Joel BodenmannJ Offline
        Joel Bodenmann
        wrote on last edited by Joel Bodenmann
        #23

        @kshegunov
        If your target processor runs on 64 MHz and has 32 kB RAM and you want to do some graphics/GUI on it, you might be thankful that there are masochistic people out there :)

        Of course I'd never do that on a desktop system.

        Actually, the real problem I see with preprocessor macros is not actually writing and maintaining them but debugging them.

        Industrial process automation software: https://simulton.com
        Embedded Graphics & GUI library: https://ugfx.io

        kshegunovK 1 Reply Last reply
        1
        • Joel BodenmannJ Joel Bodenmann

          @kshegunov
          If your target processor runs on 64 MHz and has 32 kB RAM and you want to do some graphics/GUI on it, you might be thankful that there are masochistic people out there :)

          Of course I'd never do that on a desktop system.

          Actually, the real problem I see with preprocessor macros is not actually writing and maintaining them but debugging them.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by kshegunov
          #24

          @Joel-Bodenmann
          One of the reasons I stick to real CPUs. ;)
          Joke aside, I leave that not-enough ram/CPU time struggle to engineers/embedded devs, I don't have the stomach for it to be honest. :D

          As a side note I'm not completely convinced using #define for constants is really warranted.
          If you're doing a comparison for example, this would (if I remember correctly) expand to something along the lines of:

          mov eax, 0x...      # Set the constant
          test eax, [0x...]   # Do the comparison with a field from memory
          

          If you use a simple constant (const static variable), the above should be pretty much the same:

          mov eax, [0x...]    # Set the constant (from memory this time)
          test eax, [0x...]   # Do the comparison with a field from memory
          

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved