bkc@sun.soe.clarkson.edu (Brad Clements) (03/27/88)
TurboC Bug with passing Structures to/from functions. I'm curious if anyone has heard of this problem, and a possible fix. I'm porting some code to the PC that does something like this: typedef struct { char bigstuff[16]; } Item; ... Item result, Makeit(); a() { result = Makeit(25); } Item Makeit(num) int num; { Item tmp; tmp.bigstuff[1] = num; return tmp; } According to the TurboC manual, and confirmed by examining code w/ TCD, the contents of tmp are copied to a temporary space, and the address of the temporary space is returned to function a(), which copies the data into result. The problem is that TurboC does not allocate enough space for the temporary space (namely only 4 bytes instead of the required 16 bytes) which causes other global data to get clobbered. Making tmp a static has no effect, since it still copies the data to the temporary space. I know I should be using pointers, but there are some 38,000 lines to port and it would be a pain to change. Is there a fix for TurboC for this problem? Or should I call Borland (what number) ? Any ideas would be appreciated. Brad Clements bkc@omnigate.clarkson.edu bkc@clgw.bitnet Is anyone from Borland listening? BTW: Its in the HUGE model. It uses Lots of large arrays.