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. Other Discussions
  3. IT & Infrastructure
  4. enum size compiler option

enum size compiler option

Scheduled Pinned Locked Moved IT & Infrastructure
c++question
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.
  • P Offline
    P Offline
    Priya Anand
    wrote on last edited by
    #1

    Is there any way in VC++ to make an enum field take the smallest possible size needed for that enumeration instead of 4 bytes?

    B 1 Reply Last reply
    0
    • P Priya Anand

      Is there any way in VC++ to make an enum field take the smallest possible size needed for that enumeration instead of 4 bytes?

      B Offline
      B Offline
      BAIJUMAX
      wrote on last edited by
      #2

      Hi, Answer for U r q? The #pragma enum directive specifies the size of enum variables that follow. The size at the left brace of a declaration is the one that affects that declaration, regardless of whether further enum directives occur within the declaration. This pragma pushes a value on a stack each time it is used, with a reset option available to return to the previously pushed value. usage :- #pragma enum (suboptions) where available suboptions are: small enum size is the smallest integral type that can contain all variables. int enum size is 4 1 enum size is 1 2 enum size is 2 4 enum size is 4 8 enum size is 8. int enum size is 4 intlong Specifies that enumerations occupy 8 bytes of storage and are represented by long long if the range of the constants exceed the limit for int. Otherwise, the enumerations occupy 4 bytes of storage and are represented by int. small enum size is the smallest integral type that can contain all variables. pop the option will reset the enum size to the one before the previously set enum size. reset the option is an alternative method of resetting the enum size to the one before the previously set enum size. This option is provided for backwards compatibility. by baijumax

      M 1 Reply Last reply
      0
      • B BAIJUMAX

        Hi, Answer for U r q? The #pragma enum directive specifies the size of enum variables that follow. The size at the left brace of a declaration is the one that affects that declaration, regardless of whether further enum directives occur within the declaration. This pragma pushes a value on a stack each time it is used, with a reset option available to return to the previously pushed value. usage :- #pragma enum (suboptions) where available suboptions are: small enum size is the smallest integral type that can contain all variables. int enum size is 4 1 enum size is 1 2 enum size is 2 4 enum size is 4 8 enum size is 8. int enum size is 4 intlong Specifies that enumerations occupy 8 bytes of storage and are represented by long long if the range of the constants exceed the limit for int. Otherwise, the enumerations occupy 4 bytes of storage and are represented by int. small enum size is the smallest integral type that can contain all variables. pop the option will reset the enum size to the one before the previously set enum size. reset the option is an alternative method of resetting the enum size to the one before the previously set enum size. This option is provided for backwards compatibility. by baijumax

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        Where are you getting that info? I don't see #pragma enum in the VC 6 or 7 docs. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Pinky, are you pondering what I'm pondering? I think so Brain, but if we shaved our heads, we'd look like weasels!

        B 1 Reply Last reply
        0
        • M Michael Dunn

          Where are you getting that info? I don't see #pragma enum in the VC 6 or 7 docs. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Pinky, are you pondering what I'm pondering? I think so Brain, but if we shaved our heads, we'd look like weasels!

          B Offline
          B Offline
          BAIJUMAX
          wrote on last edited by
          #4

          Hi, Sorry Wrong Compiler Option For MSVC.Currently I am using a Compiler Which Supports #pragma enum. by baijumax

          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