CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Function used but not defined - numeric values in error msg

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

Function used but not defined - numeric values in error msg
PostPosted: Thu Mar 02, 2017 12:20 pm     Reply with quote

Compiler: 5.026
Device: PIC24EP512GP806

I know this is a very trivial question and I usually know exactly the cause but this time, for the life of me, I can't find the problem.

However, regardless, what I definitely want to know once and for all are what the values mean in the error message:

*** ERROR 112 "C:\{file path\name.h}" Line 959(1,1): Function used but not defined: ... [function name] 1861 SCR=12293

So, first-off, line 959 is in a .h file which does not even have any relation to the actual function indicated in the error message. That's one issue with the compiler... pointing to some random line. But, what does the 1861 and 12293 values mean?

Thanks,

Ben
jeremiah



Joined: 20 Jul 2010
Posts: 1358

View user's profile Send private message

PostPosted: Thu Mar 02, 2017 12:56 pm     Reply with quote

I don't know what the numbers mean, but:

It would be helpful if you could post the section of code it points to (along with some before/after code for context) to see.

It could be that you have a typo in a previous line and that makes a part of your code look like a function call to your compiler and that line happens to be the one that it ends on when it makes that decision.

You probably already know this, but "function used but not defined" usually indicates you have a function defined below where it is used or not defined at all.

Example:

Code:

void some_functionA(){

   /*stuff*/

   some_functionB();  //ERROR used but not defined

}

void some_functionB(){
   /*stuff*/
}


which would be fixed with a forward declaration:

Code:

void some_functionB();  //foward declaration

void some_functionA(){

   /*stuff*/

   some_functionB();  //no error now

}

void some_functionB(){
   /*stuff*/
}
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Thu Mar 02, 2017 1:26 pm     Reply with quote

Hi Jeremiah,

I found the problem. As I mentioned, I know that this problem is usually quite simple and fair enough, I had a typo! :)

But, it would still be nice to know what those values mean just in case they point to something?

Anyhow, it's really no big deal but it would just be nice if the error messages would be explicit and point directly to the actual error and not just some random line number.

Thanks!

Ben
jeremiah



Joined: 20 Jul 2010
Posts: 1358

View user's profile Send private message

PostPosted: Thu Mar 02, 2017 3:53 pm     Reply with quote

It's not as random as you think. If you ever get a chance to, take some time to look up a tutorial on writing a basic compiler parser. The document "Let's Build a Compiler" by Jack Crenshaw is a good down to earth one that I recommend.

If you can wrap your head around how a compiler actually reads the file, then some things like this actually make a lot more sense, and it will make you better at diagnosing really weird errors.

Also consider that it's easier for the coder to kind of "arm chair captain" the compilation process and note how a compiler should be able to see something, but we look at code with a bias of knowing the intent (or possible intent) and the various patterns. The compiler has a ruleset to follow and a particular algorithm to read the file to compare it to that ruleset. It knows nothing of intent or patterns. It doesn't know that a particular typo when fixed would change the code one way or the other, so all it can do is report it relative to its algorithm.

Some compilers have gotten better about this as they have grown (GCC is much better than it used to be as is Visual Studio's compiler). But there are limits that are more based around the implementation.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group