vanam srihari kumar wrote:
I am porting code developed by using sun pc and cc compilers to gcc(2.95.2) and gpc(2.1)
Now I have landed in a preprocessor related problem,please see below code.
str_255 = PACKED ARRAY[1..256] OF CHAR; Str_ptr = ^Str_255;
strptr : str_ptr; p : str_ptr;
#define PAS_ADDTO_PTR(ptr,value) (Pointer(integer(ptr) + value)) #define PAS_TYPECAST(right, left_type) left_type(right)
p := PAS_TYPECAST(PAS_ADDTO_PTR(strptr,pos-1),str_ptr);
when I use above macros and assign the p pointer,it is pointing to junk values. But when I manually replace all the preprocessor definitions like below, it is working fine.
p := str_ptr(Pointer(integer(strptr) + (pos-1)));
Please suggest me as what to do and also let me know other bugs related to preprocessor.
Use gpc -E command to see output from preprocessor. Note that some macros are predefined, so preprocessor may be doing more expansion than you expect.