Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!gem.mps.ohio-state.edu!ginosko!ctrsol!emory!stiatl!tom From: tom@stiatl.UUCP (Tom Wiencko) Newsgroups: comp.sys.ibm.pc Subject: Re: Spurious Turbo-C warning -- how do I get around it? Keywords: Turbo-C warning Message-ID: <6913@stiatl.UUCP> Date: 18 Sep 89 15:51:12 GMT References: <5554@videovax.tv.Tek.com> Reply-To: tom@stiatl.UUCP (Tom Wiencko) Distribution: usa Organization: Wiencko & Associates, Inc. Lines: 50 In article <5554@videovax.tv.Tek.com> dougs@videovax.tv.Tek.com (Doug Stevens) writes: >>I'm trying to figure out how to get around a 'feature' of Turbo-C. >> >> #define TRUE 1 >> int test(void) >> { >> while (TRUE) { >> return(1); >> } >> } >> ... >> >>Anyone figured out a way around this? Sure... don't return out of the middle of a loop. A properly structured subroutine has ONE entry point and ONE exit point, and the entry point is at the beginning, and the exit point is at the end. The proper (structured) way to write this routine is: #define TRUE 1 int test(void) { while (TRUE) { break; } return (1); } or even better (to use the C idiom properly): int test(void) { for (;;) { break; } return (1); } In general, warnings like this are there to tell you that you are writing code which is not well structured, or is not properly taking advantage of the appropriate C idioms. Tom -- Tom Wiencko (w) (404) 977-4515 gatech!stiatl!tom Wiencko & Associates, Inc.