Hi Does anyone happen to know whether the C compiler for 5680x (either version 5.0.4 or 5.1) passes structs as pointers, or by value? I mean, does it put every byte of the struct onto the stack, or just pass a reference? For instance, would this invocation put one word on the stack for a pointer, or around 55 words of data? (I don't want to add stack check routines because I'm running out of RAM, afraid I'll overflow the stack for real, and I'm hoping someone kind already knows the answer. Other compilers pass a pointer even if you try to pass the whole struct; who knows what Metrowerks does?) typedef struct theCanMsgStruc { UWord16 CmdSeqNum; UWord16 ImuNumber; UWord16 CanPriority; UWord16 CmdCode; UWord16 MessageLen; UWord16 MsgDataByte[50]; } DummyVar3; struct theCanMsgStruc CanMsgStruct ; // variable declaration unsigned short SendCanMsg( struct theCanMsgStruc sMsgToSend ); // function prototype SendCanMsg( CanMsgStruct ); // invocation of function: note NOT &CanMsgStruct Thanks in advance. Rick Corey Senior Software Engineer DPC Instrument Systems Division |
|
does compiler pass structs as pointer, or by value?
Started by ●August 28, 2003
Reply by ●August 28, 20032003-08-28
Hi Rick, just run the di-assembly function of the Codewarrier IDE, and check the SendCanMsg() then you know it in 1 minute how the codewarrier is doing this special pass of a struct. rgds Chris >-- Original-Nachricht -- >To: "'" <> >From: "Corey, Rick" <> >Date: Thu, 28 Aug 2003 12:35:02 -0700 >Subject: [motoroladsp] does compiler pass structs as pointer, or by value? >Hi Does anyone happen to know whether the C compiler for 5680x (either version 5.0.4 or 5.1) passes structs as pointers, or by value? I mean, does it put every byte of the struct onto the stack, or just pass a reference? For instance, wou >d this invocation put one word on the stack for a pointer, or around 55 words of data? (I don't want to add stack check routines because I'm running out of RAM, afraid I'll overflow the stack for real, and I'm hoping someone kind already knows th > answer. Other compilers pass a pointer even if you try to pass the whole struct; who knows what Metrowerks does?) typedef struct theCanMsgStruc { UWord16 CmdSeqNum; UWord16 ImuNumber; UWord16 CanPriority; UWord16 CmdCode; >Word16 MessageLen; UWord16 MsgDataByte[50]; } DummyVar3; struct theCanMsgStruc CanMsgStruct ; // variable declaration unsigned short SendCanMsg( struct theCanMsgStruc sMsgToSend ); // function prot >type SendCanMsg( CanMsgStruct ); // invocation of function: note NOT &CanMsgStruct Thanks in advance. Rick Corey Senior Software Engineer DPC Instrument Systems Division ------------------------ Yahoo! Groups Sponsor ---------------- >----~--> Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cidU11 http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/PNArlB/ >M ---------------------------------~-> _____________________________________ Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a " >eply all" if you want your answer to be distributed to the entire group. _____________________________________ About this discussion group: To Join: To Post: To Leave: mot > Archives: http://www.yahoogroups.com/group/motoroladsp More Groups: http://www.dsprelated.com/groups.php3 ">http://docs.yahoo.com/info/terms/ ______________________________________ BRAUCHLI NETSOLUTION BERG BAHNHOFSTASSE 7, CH-8572 BERG SWITZERLAND TEL +41/71/6380045 FAX +41/71/6380046 MOBILE +41/78/6162214 WEB www.brauchli-netsolution.ch ______________________________________ |