Jump to content
Sign in to follow this  
djl

Improving Error Messages

Recommended Posts

It would be very nice if we could have better error messages from the compiler. Some examples:

 

Main(){}

Foo(bar){}

 

Error is: test.c(3) missing right paren

Should be something about the fact that the argument is missing a type declaration

 

#include <system.h>

Foo(int bar)
{
volatile bit b@TRISA.Bar; // <-- Note typo, B instead of b
}

 

Error is: test.c(3) missing semicolon

Should be something about undefined variable or constant

 

#include <system.h>

Foo(int bar)
{
volatile bit b@TRISA.Bar; // <-- Note typo, B instead of b

for (;;){}
while(){}
}

 

Error is: test.c(5) missing semicolon

No only is the message useless, but the reported line # is wrong (5 not 3)

 

int Foo()
{
return();
}

 

Error is: test.c (3) missing semicolon

Contrast this to the excellent, clear, descriptive error message that you get if you try to return a value from a function that is declared void:

 

void Foo()
{
return(1);
}

 

test.c(3:2) warning: function 'Foo' has return type 'void' and cannot return any value, expression ignored

 

As I come across other examples, I will post them as replies here.

Share this post


Link to post
Share on other sites

Hmmm, its now 2008 and I am still getting unhelpful/incorrect error messages

 

"error:missing right Paren" seems to be a catch al lfor amnay differnt type of errors.

 

 

It would be very nice if we could have better error messages from the compiler. Some examples:

 

Main(){}

Foo(bar){}

 

Error is: test.c(3) missing right paren

Should be something about the fact that the argument is missing a type declaration

 

#include <system.h>

Foo(int bar)
{
volatile bit b@TRISA.Bar; // <-- Note typo, B instead of b
}

 

Error is: test.c(3) missing semicolon

Should be something about undefined variable or constant

 

#include <system.h>

Foo(int bar)
{
volatile bit b@TRISA.Bar; // <-- Note typo, B instead of b

for (;;){}
while(){}
}

 

Error is: test.c(5) missing semicolon

No only is the message useless, but the reported line # is wrong (5 not 3)

 

int Foo()
{
return();
}

 

Error is: test.c (3) missing semicolon

Contrast this to the excellent, clear, descriptive error message that you get if you try to return a value from a function that is declared void:

 

void Foo()
{
return(1);
}

 

test.c(3:2) warning: function 'Foo' has return type 'void' and cannot return any value, expression ignored

 

As I come across other examples, I will post them as replies here.

Share this post


Link to post
Share on other sites

All cases have been addressed. In next release compiler will produce more meaningful error message (though still not as clear and full as you want to see).

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×