How to write C-like macros?

How do I write C-like macros in Pascal?

Simply put, how do I translate the following C statements into Pascal?

#define sqr(x) (x * x)
#define X Y
venkat_rsAsked:
Who is Participating?
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:
You could process your Pascal program through the C pre-processor.
0
venkat_rsAuthor Commented:
No, I don't want to do that! I'd like to have an equivalent of #define in my .INC file.
0
nricoCommented:
Immmmmmpossible!
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

nricoCommented:
Okay, one should never say that, especially in computer business... :-)
0
vikiingCommented:
C compiler makes "precompiling" (it's often a separated executable program), whose one of its missions is to make macro conversions.

On the other hand, Pascal nas nothing like that. You're dead.
0
scrapdogCommented:
You're totally out of luck.  Even Super-Duper-Pascal (Delphi) doesn't have this ability, though I would love to have it.

If you could do like ozo says and pipe the program from a C pre-processor to a Pascal compiler, it is possible, but may be more trouble than it is worth.

One of the characteristics of Pascal (at least Turbo and Delphi) is that it is compiled in one pass.
0
joe_hCommented:
If you are using BP, it should be possible to add something like "Preprocess & compile" to the Tools menu. You'd run cpp and then send its output to bpc (command-line BP compiler).
0
nils pipenbrinckCommented:
jep.. I agree..

there are a lot of free preprocessor tools out there.. alsmost any of them would do the job (or be cool and write one yourself).

it's not that difficult, however, I don't know how to integrate that into the bp ide.. (I guess that will be more trouble than writing the preprocessor itself).

0
sumant032199Commented:
I think that can not be done and better if we don't do it. What I mean is macros are really special things in C and C++. They are used as compiler diretive. Let this feature of C and C++ be with them alone, afterall these things are identities of C and C++ language compilers.As you may be knowing many good pascal identities are not included in latest C, C++ compilers,
why? No. Just to maintain its identity.
I think. And hence you won't find any Pascal compiler supporting C like macros.
0

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
venkat_rsAuthor Commented:
Thanx for the elaborate answer, sumant. But, my idea is not to ask for introducing #define into Pascal, but to know how I can achieve such a usage in Pascal.

Maybe, it's time I closed this question thread.
0
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
Pascal

From novice to tech pro — start learning today.