Hi
I am using gpc version 20050331, based on gcc-3.4.3 on solaris 10 intel platform.
I have a record like below
datobj_pointer = ^datobj_record;
datobj_record = RECORD next : datobj_pointer; name : PASNameString; fct : Byte_integer; phystype: phystype_list; fix_ptr : datobj_pointer; nextfct : datobj_pointer; CASE subtype : all_obj_list OF Mea : (cur_mea : meaobj_pointer; com_mea : meaobj_pointer); Ind : (cur_ind : indobj_pointer; com_ind : indobj_pointer); Tim : (cur_tim : timobj_pointer; com_tim : timobj_pointer); Scr : (cur_scr : scrobj_pointer); Evt : (cur_evt : evtobj_pointer); Cmd : (cur_cmd : cmdobj_pointer); Con : (cur_con : conobj_pointer); Tbl : (cur_tbl : tblobj_pointer); Txf : (cur_txf : txfobj_pointer); Com : (cur_com : comobj_pointer; com_com : comobj_pointer); Par : (cur_par : param_pointer; com_par : param_pointer); Slv : (cur_slv : slave_pointer ); END;
datobj : datobj_pointer;
When I call the function like below
r_w_phystype (iofil,i_o,buffer,20,datobj^.phystype,field);
I am getting below error
"variant record selector cannot be passed by reference".
Our software is working on below platforms and compilers
platform compiler sun sun pascal compiler vms vms pascal compiler digital unix digital unix pascal compiler windows borland delphi 7
In the above platforms we are not getting any problems,so please suggest whether I have any workaround?
Regards Prasad
prasad svr wrote:
Hi
I am using gpc version 20050331, based on gcc-3.4.3 on solaris 10 intel platform.
I have a record like below
datobj_pointer = ^datobj_record;
datobj_record = RECORD next : datobj_pointer; name : PASNameString; fct : Byte_integer; phystype: phystype_list; fix_ptr : datobj_pointer; nextfct : datobj_pointer; CASE subtype : all_obj_list OF Mea : (cur_mea : meaobj_pointer; com_mea : meaobj_pointer); Ind : (cur_ind : indobj_pointer; com_ind : indobj_pointer); Tim : (cur_tim : timobj_pointer; com_tim : timobj_pointer); Scr : (cur_scr : scrobj_pointer); Evt : (cur_evt : evtobj_pointer); Cmd : (cur_cmd : cmdobj_pointer); Con : (cur_con : conobj_pointer); Tbl : (cur_tbl : tblobj_pointer); Txf : (cur_txf : txfobj_pointer); Com : (cur_com : comobj_pointer; com_com : comobj_pointer); Par : (cur_par : param_pointer; com_par : param_pointer); Slv : (cur_slv : slave_pointer ); END;
datobj : datobj_pointer;
When I call the function like below
r_w_phystype (iofil,i_o,buffer,20,datobj^.phystype,field);
^^^^^^^^ do you mean `subtype' here ???
I am getting below error
"variant record selector cannot be passed by reference".
ISO Pascal forbids passing variant record selector as variable parameters. So if fifth parameter to r_w_phystype is a variable parameter and you pass the `subtype' field, then your program is violating ISO rules. Otherwise post a complete example, there is too much missing to find out why gpc prints the message.
Our software is working on below platforms and compilers
platform compiler sun sun pascal compiler vms vms pascal compiler digital unix digital unix pascal compiler windows borland delphi 7
In the above platforms we are not getting any problems,so please suggest whether I have any workaround?
I think that technically gpc could handle passing variant selectors by reference and rejects the code just because of ISO rules.
If you just want workaround, that is ugly but easy:
var subtypevar : all_obj_list;
...
subtypevar := datobj^.subtype; r_w_phystype (iofil,i_o,buffer,20,subtypevar,field); datobj^.subtype := subtypevar;
...
You can generate the above code from a macro, so the change can be limited to a few places even if you have many calls.
prasad svr wrote:
"variant record selector cannot be passed by reference".
Our software is working on below platforms and compilers
platform compiler sun sun pascal compiler vms vms pascal compiler digital unix digital unix pascal compiler windows borland delphi 7
I just checked: we allow passing variant record selector by reference in Mac Pascal mode, Borland Pascal and Borland Delphi mode. What Prasad wrote implies that we should allow it also in Vax Pascal and Sun Pascal modes. That means 5 dialects -- I propose that we turn it on by default and activate restriction only for ISO modes (and possibly USCD and Pascal SC -- I have no data for them).
Waldek Hebisch wrote:
prasad svr wrote:
"variant record selector cannot be passed by reference".
Our software is working on below platforms and compilers
platform compiler sun sun pascal compiler vms vms pascal compiler digital unix digital unix pascal compiler windows borland delphi 7
I just checked: we allow passing variant record selector by reference in Mac Pascal mode, Borland Pascal and Borland Delphi mode.
MetroWerks CodeWarrior Pascal indeed allows it.
What Prasad wrote implies that we should allow it also in Vax Pascal and Sun Pascal modes. That means 5 dialects -- I propose that we turn it on by default and activate restriction only for ISO modes (and possibly USCD and Pascal SC -- I have no data for them).
UCSD Pascal allows it also (or at least Apple UCSD Pascal 1.3 does). The abbreviation, by the way, is UCSD, from University of California at San Diego (not USCD).
Note that the "tag field cannot be passed by reference" restriction is in the ISO 7185 standard, not in the original Jensen & Wirth User Manual and Report. See Appendix E of the ISO 7185 User Manual and Report book, third edition.
Regards,
Adriaan van Os