?
Solved

c++ macro

Posted on 2003-03-25
4
Medium Priority
?
365 Views
Last Modified: 2008-03-04
I have this line in a C++ library :
#define INSTANCE_DATA_OF_PROPERTY_PTR(x) ( (PKSPROPERTY((x)) ) + 1 )
where PKSPROPERTY is a pointer type to a Record type, and x is an integer.

I'm interested in making that C++ macro, a Delphi function.
Could someone give me a hand?
The thing is I do not know for sure what's the CAST PKSPROPERTY returning... Probably the instance, or handle, or pointer memory address.

Thanks!
0
Comment
Question by:5pn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
jemax earned 100 total points
ID: 8209620
Hi 5pn,

PKSPROPERTY((x)) looks like casting in Delphi:), in C it is not.

Macro in C is just text replacement(left part of the macro is replaced by the right part keeping params ('x')) which is done before compilation by the preprocessor, so
1) ...= INSTANCE_DATA_OF_PROPERTY_PTR(x); is replaced by
2) ...= (PKSPROPERTY((x)) ) + 1;

PKSPROPERTY also looks like a macro, so look for its definition, and replace

if you find for example
#define PKSPROPERTY ((CRecord *)GetRecord(x)), so
3) ...= ((CRecord *)GetRecord(x)) + 1;

HTH,
jemax
0
 
LVL 1

Expert Comment

by:jemax
ID: 8209631

 taking in account '+1' the result, most likely, is of type integer or char*
0
 
LVL 11

Expert Comment

by:bcladd
ID: 9558889
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered: Points to jemax

Please leave any comments here within the next seven days. Experts: Silence
means you don't care.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question