Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

c++ macro

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
5pn
Asked:
5pn
  • 2
1 Solution
 
jemaxCommented:
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
 
jemaxCommented:

 taking in account '+1' the result, most likely, is of type integer or char*
0
 
bcladdCommented:
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] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now