> -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf > Of piclist@xargs.com > Sent: Thursday, February 23, 2006 6:58 PM > To: Microcontroller discussion list - Public. > Subject: RE: [PIC] 2 questions about 18f4550. > > On Thu, 23 Feb 2006, William Killian wrote: > > > There is no > > compiler that can take a function and not generate the return or the 'as > > if' version of return without guidance. > > I've been using one for years that does it. I've never had a function > that mysteriously failed to return. And I'm sure this compiler is not > unique. There is nothing mysterious. Obviously I am not getting my point across. I guess I'll have to explain things more simply. When a processor starts it always jumps to some address. Jump not call. Some are direct, some are indirect but a jump is made to that address. It is not a call. Branch on some processors is a jump and on others is a call so I'll stick with the simplest jump and call terms. Now there are two approaches we can use for the first executed code, one is have a C function at that address, while the other is an assembly language mainline code as opposed to a subroutine. The C language is defined to only have subroutines called functions. It does not have non returning 'function' types. Too bad; it is indeed a weakness for embedded work and in some cases even for non-embedded. > > > Such a compiler would have to > > be pretty good to identify a function that will never return but know it > > is not a mistake. > > I don't see it as such a difficult problem. If the last statement of > the function branches to the beginning of the function, and there are > no breaks/gotos in between that branch beyond the end of the outer > loop, why would the function need a return? There is no coding problem; the problem lies elsewhere possibly in comprehension. Since I intend to assume the best about you, it seems you obviously are not getting the point. It does not need a return. You are indeed correct. That is my entire point. But, how does the compiler know that? How does it know that it can appropriately not generate any entrance and exit code? Because you wrote the function like that? What if that is an error and you would have wanted a warning about 'non reachable code' or 'function does not exit'. Sure in a non multitasking word that is sometimes 'just one function'. In a multi-tasking world it is not. Quite a few times I've stumbled across applications - such as the slot machine I am working on now - that has quite a few layers of functions called before you even get into the one that has the endless loop. This is a PIC list but the issue is relevant more to non PIC chips in this case. ------------------------------------- Notice of Confidentiality ---------------------------------------------------------- This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify postmaster@vgt.net. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist