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;
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
add a comment |
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
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
add a comment |
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
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
c++ c class enums structure
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
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?
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
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
add a comment |
add a comment |
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?
add a comment |
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?
add a comment |
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?
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?
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
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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