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. A complex macro definition

A complex macro definition

Scheduled Pinned Locked Moved C / C++ / MFC
5 Posts 2 Posters 1 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.
  • S Offline
    S Offline
    samzcs
    wrote on last edited by
    #1

    define blHeadTable ((V_ROM1_FAR tblHead V_ROM2_FAR V_ROM3 *)(BL_HEAD_ADDRESS))

    define GetblDID1() (blHeadTable->DID[1])

    I am a little confused in the first macro declaration. Appreciate any explanation.

    J 1 Reply Last reply
    0
    • S samzcs

      define blHeadTable ((V_ROM1_FAR tblHead V_ROM2_FAR V_ROM3 *)(BL_HEAD_ADDRESS))

      define GetblDID1() (blHeadTable->DID[1])

      I am a little confused in the first macro declaration. Appreciate any explanation.

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      Basically it casts the fixed address BL_HEAD_ADDRESS as a pointer to some type:

      # define someTypeAddr ((someType *)(BL_HEAD_ADDRESS))

      In your case the type is V_ROM1_FAR tblHead V_ROM2_FAR V_ROM3. Assuming that V_ROM1_FAR and V_ROM2_FAR are something like far *, the type is a pointer in V_ROM3 that points to a tblHead pointer. Effectively it will assign a pointer to a tblHead structure at a fixed address.

      S 2 Replies Last reply
      0
      • J Jochen Arndt

        Basically it casts the fixed address BL_HEAD_ADDRESS as a pointer to some type:

        # define someTypeAddr ((someType *)(BL_HEAD_ADDRESS))

        In your case the type is V_ROM1_FAR tblHead V_ROM2_FAR V_ROM3. Assuming that V_ROM1_FAR and V_ROM2_FAR are something like far *, the type is a pointer in V_ROM3 that points to a tblHead pointer. Effectively it will assign a pointer to a tblHead structure at a fixed address.

        S Offline
        S Offline
        samzcs
        wrote on last edited by
        #3

        I understand it's like:

        # define someTypeAddr ((someType *)(BL_HEAD_ADDRESS))

        But the type:

        V_ROM1_FAR tblHead V_ROM2_FAR V_ROM3

        I am still a little confused with it.

        int a Char short, is that similar?

        Thanks

        J 1 Reply Last reply
        0
        • S samzcs

          I understand it's like:

          # define someTypeAddr ((someType *)(BL_HEAD_ADDRESS))

          But the type:

          V_ROM1_FAR tblHead V_ROM2_FAR V_ROM3

          I am still a little confused with it.

          int a Char short, is that similar?

          Thanks

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #4

          You have to lookup first how V_ROM1_FAR and V_ROM2_FAR are defined. Then it will be something like

          far * tblHead far * V_ROM3

          far is a compiler and platform specific keyword. See Far pointer - Wikipedia[^]. See also Cx51 User's Guide: Abstract Pointers[^] (I did not found a better link that explains such castings).

          1 Reply Last reply
          0
          • J Jochen Arndt

            Basically it casts the fixed address BL_HEAD_ADDRESS as a pointer to some type:

            # define someTypeAddr ((someType *)(BL_HEAD_ADDRESS))

            In your case the type is V_ROM1_FAR tblHead V_ROM2_FAR V_ROM3. Assuming that V_ROM1_FAR and V_ROM2_FAR are something like far *, the type is a pointer in V_ROM3 that points to a tblHead pointer. Effectively it will assign a pointer to a tblHead structure at a fixed address.

            S Offline
            S Offline
            samzcs
            wrote on last edited by
            #5

            Thanks, I understand it. Looked into V_ROM2_FAR V_ROM3, V_ROM2_FAR be defined as const, V_ROM3 blank

            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