Sei sulla pagina 1di 4

Analysis of Compile Time Errors

Background
Many of the submissions in Practice round ended in Compile-Time Error. Of these, majority of these messages were received for C/C++ submissions, some for Java and some for C#. This is largely because majority of the submissions were in C/C++. In the next section, this document enumerates the actual list of compilation errors that were caught. Readers should relate it back to their environments. It is almost impossible to categorize every compilation error that was every received. So, it is possible that you may not have committed any of these mistakes but still have received Compile-Time Error messages.

Having said that, I declare that Compile-Time Error message is NOT a generic message. A submission will never receive Compile-Time Error message unless the code is found wanting in some of the technical aspects related to compilation process. Likewise, the submission will NEVER receive CompileTime Error message if the code compiles cleanly without any warnings, irrespective of the (permitted) languages used for submission. The compilation commands that may be used (but are subject to change depending on contest factors such as concurrency etc) in CodeVita 2013 contests for different languages are as depicted below.

Compilation Commands Language C C++ Java C# Perl, Python and Ruby Command gcc Wall lm yourfile g++ -Wall lm yourfile javac yourfile mcs yourfile NA since these are interpreted languages

Compile-Time Error Classification


The following tables denote the broad classes of compilation errors. The tables contain status messages returned by the compiler as well as remarks from us.

Sr. No 1

Error class

Associated message from Compiler Return type of main is not int

Remarks Although this is not an error, just a warning, Codevita systems treat this as error. In previous documents in was mentioned that C/C++ main() should return 0. It is likely that participants IDE may have not displayed this warning to the participant. Hence the code ran successfully on participant machine. format '%d' expects type 'int *', but This should have been corrected argument 2 has type 'long int *' by the participant before submission. implicit declaration of function Attempt to use a conio.h function 'getch' which does not exist in gcc implicit declaration 'toascii' and isdigit of function

Although these are valid C functions, these exist in ctype.h in gcc. Either the user has not used gcc for compilation or has Warnings treated forgotten to #include<ctype.h> as errors the `gets' function is dangerous and Gcc gives such a warning when should not be used. using gets function to read inputs from console. Either the user has not used gcc for compilation or ignored previous documents which advised use of scanf() to read inputs. Unused variable Gcc issues a warning. Hence CodeVita system marks it as an error. Cin / cout / new / delete undeclared Attempt to submit C++ code as C (first use in this function) code. control reaches end of non-void When main() is declared without function return type (either void or int), gcc issues this warning. Either the user has not used gcc for compilation or ignored this warning during compilation at his/her end.

10 11

13

14

15

16

17

18

Comparison between signed and Gcc issues a warning. Either the unsigned integer user has not used gcc for compilation or ignored this warning during compilation at his/her end. Use of Deprecated methods in Java Previous documents had mentioned this to be avoided. Use of functions such as toascii, Although these are valid C Use of invalid isdigit, getch etc. functions, these exist in ctype.h in APIs gcc. Either the user has not used gcc for compilation or has forgotten to #include<ctype.h> or #include<curses.h> Missing terminating character The participant has not bothered to compile the code even on his/her system. This is an error irrespective of the compilers used. conio.h: No such file or directory It had been specified in the question text also, that conio.h does not exist in gcc. Array dimension missing Error on any compiler. This occurred in C# during the competition. Cannot implicitly convert String to int The participant has not bothered to participate the code even on his/her system. This is an error irrespective of the compilers used. Silly Mistakes Public class XYZ should be declared in Basic java knowledge. Participant a file called XYZ.java should improve knowledge on how to write Java classes. Declaring Java classes in packages Code should not be packaged in packages or namespaces in C++/Java and C#. This mistake has been committed by a few participants. We feel this error is caused by default behavior of some of the IDEs which package code in a package by default. Participant should be alert at submission time and should remove the package declaration.

Closing Comments
Many Compile-Time Errors could have been avoided if 1. Participants would have used notepad / vi editors and compiled the programs on command line at their end. This way they would not have been blinded by the IDE. A simple trick that, if the compiler returns any text message, then this will result in compilation errors in CodeVita .If participants would have been alert of this fact it would have saved a lot of efforts for them. 2. Continuing to use compilers like Turbo C, Borland C AND not knowing how to get these programs compiled on gcc proved to bring downfall for many participants. The compiler names and versions were released long time ago and participants should have shown urgency to install those compilers in their environment. 3. Care would have been taken to meticulously adhere to input / output specifications. Also, a change in thinking would have helped at this point in time. For e.g. if the participants would have thought about why others submissions are able to get past compilation errors, they would have been in position to introspect deeply and figure out the mistake themselves. Many participants at this stage created a wall around themselves by thinking My code compiles in my environment, so something must be wrong with CodeVita systems. This is clearly a wrong way to think. Ensuring code portability is participant responsibility.

Thank you for your participation.

CodeVita Digitization Team

Potrebbero piacerti anche