c++ - Code checking
- SD (14/14) Oct 05 2002 Hi,
- Larry Brasfield (12/25) Oct 05 2002 If you want better compile-time checking, why
- SD (6/30) Oct 05 2002 Thk for the prompt reply.
- bw (2/9) Oct 05 2002 got version 8.29 ?
- SD (2/18) Oct 06 2002
- bw (26/28) Oct 06 2002 the 8.29 i have catches all those, don't understand why you're having tr...
- Rajiv Bhagwat (16/46) Oct 07 2002 'main' is required to be treated by compilers as a special function (to ...
- SD (6/45) Oct 08 2002 Hi
Hi, I am using the C compiler with the maximum checking option I found, -A -w- -r. However, the compiler does not check the possible errors as I would like, ie : - I declared main() as returning a void, and the compiler did not complain. - I declared a function returning an int, and I do not use return statement in the function body. Again, the compiler does not complain. - I use a function without declaring the prototype. The compiler says nothing. Is there a compiler option I have not seen, or the compiler does not make these controls ? Thx SD
Oct 05 2002
In article <ann0hg$16cs$1 digitaldaemon.com>, SD (stephanedelaval wanadoo.fr) says...Hi, I am using the C compiler with the maximum checking option I found, -A -w- -r. However, the compiler does not check the possible errors as I would like, ie : - I declared main() as returning a void, and the compiler did not complain. - I declared a function returning an int, and I do not use return statement in the function body. Again, the compiler does not complain. - I use a function without declaring the prototype. The compiler says nothing. Is there a compiler option I have not seen, or the compiler does not make these controls ?If you want better compile-time checking, why not compile your C programs using the C++ compiler? It's been awhile since I used C very much, but I recall that the issues you object to were not errors according to the C language. Those and many other needless lapses were tightened up in C++. -- -Larry Brasfield (address munged, s/sn/h/ to reply)
Oct 05 2002
Thk for the prompt reply. You are suggesting a very good solution. However I used the -cpp option of the sc.exe dmars compiler, and it still have the same problem. Is there another C++ compiler in the digital mars package ? Except for this flag, I have not seen any reference for it... SDIn article <ann0hg$16cs$1 digitaldaemon.com>, SD (stephanedelaval wanadoo.fr) says...Hi, I am using the C compiler with the maximum checking option I found, -A -w- -r. However, the compiler does not check the possible errors as I would like, ie : - I declared main() as returning a void, and the compiler did not complain. - I declared a function returning an int, and I do not use return statement in the function body. Again, the compiler does not complain. - I use a function without declaring the prototype. The compiler says nothing. Is there a compiler option I have not seen, or the compiler does not make these controls ?If you want better compile-time checking, why not compile your C programs using the C++ compiler? It's been awhile since I used C very much, but I recall that the issues you object to were not errors according to the C language. Those and many other needless lapses were tightened up in C++.
Oct 05 2002
In article <ann7mi$1cj9$1 digitaldaemon.com>, SD says...got version 8.29 ?However, the compiler does not check the possible errors as I would like, ie : - I declared main() as returning a void, and the compiler did not complain. - I declared a function returning an int, and I do not use return statement in the function body. Again, the compiler does not complain. - I use a function without declaring the prototype. The compiler says nothing.
Oct 05 2002
Yes, I have the latest available. bw <bw_member pathlink.com> wrote in news:annuff$24fi$1 digitaldaemon.com:In article <ann7mi$1cj9$1 digitaldaemon.com>, SD says...got version 8.29 ?However, the compiler does not check the possible errors as I would like, ie : - I declared main() as returning a void, and the compiler did not complain. - I declared a function returning an int, and I do not use return statement in the function body. Again, the compiler does not complain. - I use a function without declaring the prototype. The compiler says nothing.
Oct 06 2002
In article <anosh8$ke$1 digitaldaemon.com>, SD says...Yes, I have the latest available.the 8.29 i have catches all those, don't understand why you're having trouble? /* testing for errors */ #include <stdio.h> void main(void) { func(); } int func() { } C:\cpp\my>sc -A -w- -r errs.c func(); ^ errs.c(8) : Error: function 'func' has no prototype errs.c(15) : Error: need at least one external def --- errorlevel 1 C:\cpp\my>sc -A -w- -r -cpp errs.c func(); ^ errs.c(8) : Error: function 'func' has no prototype } ^ errs.c(14) : Error: implied return of func at closing '}' does not return value errs.c(15) : Error: need at least one external def --- errorlevel 1got version 8.29 ?
Oct 06 2002
'main' is required to be treated by compilers as a special function (to not break old code), and thus only for 'main' it is legal to declare it as 'void', declare it as int and not return a value. Remember, in older versions of C, a function without type declaration was treated as returning an int, and even then, it was ok for it to not return anything. afunction(){ ... } is in reality an 'int' function. These topics have been widely discussed in C computer magazines and I recollect have been elucidated in the ARM (Annotated Reference Manual), the standard which talks about C/C++. - Rajiv "bw" <bw_member pathlink.com> wrote in message news:anpfnv$ikk$1 digitaldaemon.com...In article <anosh8$ke$1 digitaldaemon.com>, SD says...trouble?Yes, I have the latest available.the 8.29 i have catches all those, don't understand why you're havinggot version 8.29 ?/* testing for errors */ #include <stdio.h> void main(void) { func(); } int func() { } C:\cpp\my>sc -A -w- -r errs.c func(); ^ errs.c(8) : Error: function 'func' has no prototype errs.c(15) : Error: need at least one external def --- errorlevel 1 C:\cpp\my>sc -A -w- -r -cpp errs.c func(); ^ errs.c(8) : Error: function 'func' has no prototype } ^ errs.c(14) : Error: implied return of func at closing '}' does not returnvalueerrs.c(15) : Error: need at least one external def --- errorlevel 1
Oct 07 2002
Hi OK, that's fine now. I think the -cpp flag made the difference. Mny thanks Stephane bw <bw_member pathlink.com> wrote in news:anpfnv$ikk$1 digitaldaemon.com:In article <anosh8$ke$1 digitaldaemon.com>, SD says...Yes, I have the latest available.the 8.29 i have catches all those, don't understand why you're having trouble? /* testing for errors */ #include <stdio.h> void main(void) { func(); } int func() { } C:\cpp\my>sc -A -w- -r errs.c func(); ^ errs.c(8) : Error: function 'func' has no prototype errs.c(15) : Error: need at least one external def --- errorlevel 1 C:\cpp\my>sc -A -w- -r -cpp errs.c func(); ^ errs.c(8) : Error: function 'func' has no prototype } ^ errs.c(14) : Error: implied return of func at closing '}' does not return value errs.c(15) : Error: need at least one external def --- errorlevel 1got version 8.29 ?
Oct 08 2002