How can I convert enum in C++ code into CHow to emulate strongly typed enum in C?Cast int to enum in C#What are the differences between a pointer variable and a reference variable in C++?How do I enumerate an enum in C#?What is the preferred syntax for defining enums in JavaScript?The Definitive C++ Book Guide and ListHow to get an enum value from a string value in Java?What is the “-->” operator in C++?Improve INSERT-per-second performance of SQLite?What is the copy-and-swap idiom?Why is processing a sorted array faster than processing an unsorted array?

How can a dictatorship government be beneficial to a dictator in a post-scarcity society?

Why was hardware diversification an asset for the IBM PC ecosystem?

How can I calculate the sum of 2 random dice out of a 3d6 pool in AnyDice?

Storming Area 51

Cops: The Hidden OEIS Substring

What is a solution?

Why isn't pressure filtration popular compared to vacuum filtration?

How would my creatures handle groups without a strong concept of numbers?

How to memorize multiple pieces?

Why didn't Nick Fury expose the villain's identity and plans?

How did the hit man miss?

Is anyone advocating the promotion of homosexuality in UK schools?

Does Lufthansa weigh your carry on luggage?

Why does the U.S. tolerate foreign influence from Saudi Arabia and Israel on its domestic policies while not tolerating that from China or Russia?

What's the minimum number of sensors for a hobby GPS waypoint-following UAV?

Single word for "refusing to move to next activity unless present one is completed."

Changing trains in the Netherlands

Why are Hobbits so fond of mushrooms?

Terry Pratchett book with a lawyer dragon and sheep

definition of "percentile"

Combining latex input and sed

Why do players in the past play much longer tournaments than today's top players?

Why do people keep referring to Leia as Princess Leia, even after the destruction of Alderaan?

Referring to different instances of the same character in time travel



How can I convert enum in C++ code into C


How to emulate strongly typed enum in C?Cast int to enum in C#What are the differences between a pointer variable and a reference variable in C++?How do I enumerate an enum in C#?What is the preferred syntax for defining enums in JavaScript?The Definitive C++ Book Guide and ListHow to get an enum value from a string value in Java?What is the “-->” operator in C++?Improve INSERT-per-second performance of SQLite?What is the copy-and-swap idiom?Why is processing a sorted array faster than processing an unsorted array?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am converting C++ code to C code. Here is the code which needs to be converted-



struct new
enum new_enum:uint8_t
head = 1,
tail = 2,
data = 3,
;
;


How to convert this? Can someone explain what is uint8_t in enum? Is it assigning all variables to uint8_t?










share|improve this question






















  • converting C++ code to C code is quite unclear. Do you want to convert the the enum value to its underlying integral value ?

    – aep
    Mar 26 at 3:05

















0















I am converting C++ code to C code. Here is the code which needs to be converted-



struct new
enum new_enum:uint8_t
head = 1,
tail = 2,
data = 3,
;
;


How to convert this? Can someone explain what is uint8_t in enum? Is it assigning all variables to uint8_t?










share|improve this question






















  • converting C++ code to C code is quite unclear. Do you want to convert the the enum value to its underlying integral value ?

    – aep
    Mar 26 at 3:05













0












0








0








I am converting C++ code to C code. Here is the code which needs to be converted-



struct new
enum new_enum:uint8_t
head = 1,
tail = 2,
data = 3,
;
;


How to convert this? Can someone explain what is uint8_t in enum? Is it assigning all variables to uint8_t?










share|improve this question














I am converting C++ code to C code. Here is the code which needs to be converted-



struct new
enum new_enum:uint8_t
head = 1,
tail = 2,
data = 3,
;
;


How to convert this? Can someone explain what is uint8_t in enum? Is it assigning all variables to uint8_t?







c++ c class enums structure






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 2:27









user2824459user2824459

1




1












  • converting C++ code to C code is quite unclear. Do you want to convert the the enum value to its underlying integral value ?

    – aep
    Mar 26 at 3:05

















  • converting C++ code to C code is quite unclear. Do you want to convert the the enum value to its underlying integral value ?

    – aep
    Mar 26 at 3:05
















converting C++ code to C code is quite unclear. Do you want to convert the the enum value to its underlying integral value ?

– aep
Mar 26 at 3:05





converting C++ code to C code is quite unclear. Do you want to convert the the enum value to its underlying integral value ?

– aep
Mar 26 at 3:05












2 Answers
2






active

oldest

votes


















2














The code you provide cannot compile in C++, since the struct name is new.



Anyway, you can try to just drop the :uint8_t. This will change the strongly typed enum to a standard C one. If you are lucky everything will work. If in any other point you have an use of head, tail or data, it won't work. You can do this:



enum new_enum 
new_enum_head = 1,
new_enum_tail = 2,
new_enum_data = 3,
;


Ugly, but likely to work. Of course the enum will have to go out of the struct it was defined in. That again can cause a lot of grief, but less likely.






share|improve this answer






























    0















    I am converting C++ code to C code.




    This this seems like a strange direction to take.



    There is no direct conversion here. Typed enums are a c++ feature.



    There is a similar question here: How to emulate strongly typed enum in C?






    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349000%2fhow-can-i-convert-enum-in-c-code-into-c%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      The code you provide cannot compile in C++, since the struct name is new.



      Anyway, you can try to just drop the :uint8_t. This will change the strongly typed enum to a standard C one. If you are lucky everything will work. If in any other point you have an use of head, tail or data, it won't work. You can do this:



      enum new_enum 
      new_enum_head = 1,
      new_enum_tail = 2,
      new_enum_data = 3,
      ;


      Ugly, but likely to work. Of course the enum will have to go out of the struct it was defined in. That again can cause a lot of grief, but less likely.






      share|improve this answer



























        2














        The code you provide cannot compile in C++, since the struct name is new.



        Anyway, you can try to just drop the :uint8_t. This will change the strongly typed enum to a standard C one. If you are lucky everything will work. If in any other point you have an use of head, tail or data, it won't work. You can do this:



        enum new_enum 
        new_enum_head = 1,
        new_enum_tail = 2,
        new_enum_data = 3,
        ;


        Ugly, but likely to work. Of course the enum will have to go out of the struct it was defined in. That again can cause a lot of grief, but less likely.






        share|improve this answer

























          2












          2








          2







          The code you provide cannot compile in C++, since the struct name is new.



          Anyway, you can try to just drop the :uint8_t. This will change the strongly typed enum to a standard C one. If you are lucky everything will work. If in any other point you have an use of head, tail or data, it won't work. You can do this:



          enum new_enum 
          new_enum_head = 1,
          new_enum_tail = 2,
          new_enum_data = 3,
          ;


          Ugly, but likely to work. Of course the enum will have to go out of the struct it was defined in. That again can cause a lot of grief, but less likely.






          share|improve this answer













          The code you provide cannot compile in C++, since the struct name is new.



          Anyway, you can try to just drop the :uint8_t. This will change the strongly typed enum to a standard C one. If you are lucky everything will work. If in any other point you have an use of head, tail or data, it won't work. You can do this:



          enum new_enum 
          new_enum_head = 1,
          new_enum_tail = 2,
          new_enum_data = 3,
          ;


          Ugly, but likely to work. Of course the enum will have to go out of the struct it was defined in. That again can cause a lot of grief, but less likely.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 26 at 3:50









          Costantino GranaCostantino Grana

          1,1291 gold badge7 silver badges23 bronze badges




          1,1291 gold badge7 silver badges23 bronze badges























              0















              I am converting C++ code to C code.




              This this seems like a strange direction to take.



              There is no direct conversion here. Typed enums are a c++ feature.



              There is a similar question here: How to emulate strongly typed enum in C?






              share|improve this answer



























                0















                I am converting C++ code to C code.




                This this seems like a strange direction to take.



                There is no direct conversion here. Typed enums are a c++ feature.



                There is a similar question here: How to emulate strongly typed enum in C?






                share|improve this answer

























                  0












                  0








                  0








                  I am converting C++ code to C code.




                  This this seems like a strange direction to take.



                  There is no direct conversion here. Typed enums are a c++ feature.



                  There is a similar question here: How to emulate strongly typed enum in C?






                  share|improve this answer














                  I am converting C++ code to C code.




                  This this seems like a strange direction to take.



                  There is no direct conversion here. Typed enums are a c++ feature.



                  There is a similar question here: How to emulate strongly typed enum in C?







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 26 at 2:32









                  Richard HodgesRichard Hodges

                  57.8k6 gold badges60 silver badges107 bronze badges




                  57.8k6 gold badges60 silver badges107 bronze badges



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349000%2fhow-can-i-convert-enum-in-c-code-into-c%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                      Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript