Git 基础 - 打标签
=Ditaa= Source Code Blocks in Org Mode

Convert enumerator names to string in C/C++

tubo posted @ 2014年11月06日 18:20 in 未分类 , 1916 阅读

From stackoverflow

Another way, making the preprocessor do the work. It also ensures your enums and strings are in sync.

#define FOREACH_FRUIT(FRUIT) \
        FRUIT(apple)   \
        FRUIT(orange)  \
        FRUIT(grape)   \
        FRUIT(banana)  \

#define GENERATE_ENUM(ENUM) ENUM,
#define GENERATE_STRING(STRING) #STRING,

enum FRUIT_ENUM {
    FOREACH_FRUIT(GENERATE_ENUM)
};

static const char *FRUIT_STRING[] = {
    FOREACH_FRUIT(GENERATE_STRING)
};

After the preprocessor gets done, you'll have:

enum FRUIT_ENUM {
    apple, orange, grape, banana,
};

static const char *FRUIT_STRING[] = {
    "apple", "orange", "grape", "banana",
};

Then you could do something like:

printf("enum apple as a string: %s\n",FRUIT_STRING[apple]);

Another way, if the use case is literally just printing the enum name:

#define str(x) #x
#define xstr(x) str(x)

Then do:

printf("enum apple as a string: %s\n", xstr(apple));

 

Fadden 说:
2019年4月01日 18:39

I have to convert those names with the all updates of the new to all old variant by the figure out depends to use. Generate about the strings on the custom essay writing services uk will not be figure it out actual in the genially.

Dignissimos dolor vo 说:
2019年7月24日 23:45

[essaymama.com review](https://www.essaywritingboo.com/essaymama-com-review/)

"school assignment help":https://www.essaywritinglab.co.uk/assignment/
[assignment writing help australia|https://myassignments-help.com.au/]
[[https://www.dissertationhqhelp.com/expert-writers-net-review-5-10/|expert writers reviews ]]

<a href="https://www.essaywritinglab.co.uk/" style="background-color: rgb(3, 255, 11); border: 1px dashed black;">paper writing service</a>

jaimeallen 说:
2019年8月30日 03:53

I was in the rubyfortune nz casino. I got some answers concerning this at the site. You can feel free to look into every one of the subtleties there, too.

alex 说:
2019年9月16日 03:02

hey i am doing a work for backlink 50 comment only for 5$ in one or two days for the website go to https://www.fiverr.com/alex5478/do-50-backlink-comment
thanks

Jerry 说:
2019年10月09日 22:42

If you want to win $5000 gift card for free then you must participate in the official <a href="https://www.homedepotcomsurveys.com/">homedepot.com survey</a> and win $5000 gift card for free. Home Depot store management is conducting this survey to their customers to take the feedback about their store and using that feedback they want to improve their services.

Jerry 说:
2019年10月09日 22:44

[url=www.google.com]google[/url]

Jerry 说:
2019年10月09日 22:48

If you want to win $5000 gift card for free then you must participate in the official <a href="https://www.homedepotcomsurveys.com/">homedepot.com survey</a> and win $5000 gift card for free. Home Depot store management is conducting this survey to their customers to take the feedback about their store and using that feedback they want to improve their services.

abrar 说:
2019年10月19日 01:28

If you want to win $5000 gift card for free then you must participate in the official <a href="https://www.homedepotcomsurveys.com/">homedepot.com survey</a> and win $5000 gift card for free. Home Depot store management is conducting this survey to their customers to take the feedback about their store and using that feedback they want to<a href="https://www.fiverr.com/alex5478/do-50-backlink-comment" style="font-size: 11px;" target="_self">backlinks</a>

abrar 说:
2019年11月01日 18:43

. I got some answers concerning this at the site. You can feel free to look into every one of the subtleties there, too
[url=https://www.fiverr.com/alex5478/do-50-backlink-comment]backlinks [/url]

jafir 说:
2020年2月01日 04:21

At that point along came the link organizations. Out of nowhere we could encounter radically improved nature of sound, video and obviously content, as they gave access to an a lot more extensive scope of channels. Binge

itsmonika 说:
2020年6月15日 22:37
C++ was my favorite subject all the time. I just found it difficult to understand the loop and run the loop but Assignment writing services did not let me down. I hired a tutor online, and he taught me very well about loops. 
 
backlinks 说:
2020年6月16日 05:11

Backlinking is only one bit of the total positioning algorithmic program for all the web search tools however is one of the key impacts in getting a webpage to rank impressively high guaranteeing it remains along these lines into what's to come. Dofollow backlinks

Dofollow backlinks 说:
2020年7月13日 10:01

So as to make effective backlinks, you have to manufacture connections. There are a ton of ways that individuals will take a shot at their backlinks, and a ton just requires contacts.

Dofollow backlinks 说:
2021年2月16日 05:00

I read your blog it's a very interesting and good blog.if you want good traffic and good earning so you must go backlinks. we provide good and quility

alex 说:
2021年6月05日 01:30

Those individuals can appreciate online, as given ruby fortune online casino for new zealand in this post we can appreciate online games. The pixels in this game are great to such an extent that when we play we appreciate it a ton.<a href="https://www.fiverr.com/faizan_5478/convert-psd-to-html-css-and-bootstrap-in-high-quality">(Free) Web Development</a>

alex 说:
2021年6月05日 01:31

Those individuals can appreciate online, as given ruby fortune online casino for new zealand in this post we can appreciate online games. The pixels in this game are great to such an extent that when we play we appreciate it a ton https://www.fiverr.com/faizan_5478/convert-psd-to-html-css-and-bootstrap-in-high-quality

do my assignment for 说:
2021年7月07日 00:01

If you are looking for an online writing company to ask them ‘do my assignment for me uk" EssaysnAssignments Services UK is the right place.
We are providing high-quality services at low prices to help students ace their results. Get 100% Plagiarism Free Work by 5000+ experts to secure your A+ Grade.

housekeeping service 说:
2021年8月26日 23:57

Great kitchen maintaining involves cleaning in all areas to a commercial your kitchen's, including that ceiling, floorboards, equipment, training tables and even walls. The exact focus of any such kitchen cleaning may be to find areas that can be out in reach for the period of regular protection drills.

nanny services in du 说:
2021年8月31日 21:11

you ought to remember which will cleaning companies typically are not maid expertise. They do not jump together and achieve your containers and walk your pup and find your dusty socks. You are doing all about this beforehand. They will pay attention to everything as well. If you should have your flooring cleaned additionally they offer which will service, they will likely do the application. If you should have your bare floors mopped and even cleaned, they will likely do the application. But it's at your discretion in order that it was at least some swept together. If you may be older on age, you want to enlist the aid of a neighbor or a different person that one trust to help you to tidy up beforehand. However, leave the other parts to that cleaning company-they're there that will.

part time maids in d 说:
2023年8月12日 00:19

Superior quality is in accordance with the fee. If the debtor believes of the fact that painting assess is likewise low they might suspect that the application contractor is normally either poor balling, inexperienced or possibly cutting price ranges by cheapening your responsibilities not directly or an alternative. The customer will then believe that they will be not getting value from which usually paint estimate all of which not still from which usually contractor despite that the price is lower.

house cleaning servi 说:
2024年1月31日 23:46

An alternative reason to engage verified maids can be to help your house be valuables safe into your absence. Nobody wishes to be latest while cleaning is accomplished. But also normally would of that ranking their belongings are compromised. To evade this ask the housecleaning company if for example the maids coming at your house . have been subject to proper verification process.

Freetubespot 说:
2024年2月15日 00:39

Freetubespot offers a comprehensive suite of tools to cater to the diverse needs and preferences of its users. With seamless navigation and intuitive controls, Freetubespot ensures that every moment spent on the platform is a delight.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter