A way to create a macro table? (or: a #define that expands to multiple #defines)

Hello, in my C program I need to define a large number of max/min/default values.  Here is the long way:

#define MIN_X 15
#define MAX_X 75
#define DFLT_X 20
#define MIN_Y 0
#define MAX_Y 1024
#define DFLT_Y 200
... and so on for a few hundred parameters.

This would be much more readable/maintainable if I could do this in tabular form, and I'm wondering if there is a clever macro that can help, and would expand to the above, such as:

#define DEFINE_MIN_MAX_DEFAULT(X,15,75,20)
#define DEFINE_MIN_MAX_DEFAULT(Y,0,1024,200)

or even this, if it is easier:

#define DEFINE_MULTIPLE(MIN_X, 15, MAX_X, 75, DFLT_X, 20)
#define DEFINE_MULTIPLE(MIN_Y, 0, MAX_Y, 1024, DFLT_Y,  200)


Either of these will result in much easier-to-read code.  In short, is there any way to define a macro that will expand to multiple #define macros?
RonMexicoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
Instead of #define, could you use
const int MIN_X = 15;
const int MAX_X = 75;
...
RonMexicoAuthor Commented:
Hm, I'd never seen/used that, so it's interesting.  But how would that help me arrange my data in a tabular format (ie columns are MAX, MIN, DEFAULT)?  The way you write it it would still be three rows per variable.

Sorry if that objective wasn't clear from the question.
ozoCommented:
#define DEFINE_MIN_MAX_DEFAULT(x,min,max,dflt) \
constexpr int MIN_##x = min; \
constexpr int MAX_##x = max; \
constexpr int DFLT_##x = dflt;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

RonMexicoAuthor Commented:
Oh... clever!  And wow... token pasting!

Are there any drawbacks to constexpr vs #define?  I see that it is "evaluated at compile time", but does it make your program bigger, or take up memory?
RonMexicoAuthor Commented:
Hm, unfortunately I don't have a newer C compiler... constexpr doesn't seem to be supported.
ozoCommented:
I think const is slightly older than constexpr although there are slightly fewer contexts where it would be valid.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.