My Math Forum  

Go Back   My Math Forum > Science Forums > Computer Science

Computer Science Computer Science Forum


Thanks Tree4Thanks
  • 1 Post By MathsLearner123
  • 1 Post By skipjack
  • 1 Post By skipjack
  • 1 Post By greg1313
Reply
 
LinkBack Thread Tools Display Modes
July 28th, 2018, 06:25 AM   #1
Banned Camp
 
Joined: Jul 2018
From: INDIA

Posts: 93
Thanks: 0

what is error in this code

hello
what is error in this mplab hi tech c compiler
#include <htc.h>
#define _XTAL_FREQ 8000000
void main()
{
TRISB=0x00;
PORTB=0x00;
while(1)
{
PORTB=0xFF;
__delay_ms(1000);
PORTB=0x00;
__delay_ms(1000);
}
}Error [499] ; . undefined symbol:
___delay_ms (INDIAA.obj)

********** Build failed! **********
EBTERTTBT is offline  
 
July 28th, 2018, 06:41 AM   #2
Member
 
Joined: Aug 2017
From: India

Posts: 48
Thanks: 2

delay_ms function is not defined.
Thanks from babaliaris
MathsLearner123 is offline  
July 28th, 2018, 10:13 AM   #3
Global Moderator
 
Joined: Dec 2006

Posts: 19,878
Thanks: 1835

It's __delay_ms that's undefined. If the code was based on working code, that working code probably included another .h file which had the necessary definition.
Thanks from babaliaris
skipjack is offline  
July 28th, 2018, 12:09 PM   #4
Math Team
 
Joined: Oct 2011
From: Ottawa Ontario, Canada

Posts: 13,468
Thanks: 949

Why d'hell can't it be a simple "pause(?)" command,
like my beloved UBasic
Denis is offline  
July 28th, 2018, 12:10 PM   #5
Member
 
Joined: Aug 2017
From: India

Posts: 48
Thanks: 2

Quote:
Originally Posted by skipjack View Post
It's __delay_ms that's undefined. If the code was based on working code, that working code probably included another .h file which had the necessary definition.
But the definition generally will be available in .c file but not sure. The declaration will be available in .h file i think.
MathsLearner123 is offline  
July 29th, 2018, 01:21 AM   #6
Global Moderator
 
Joined: Dec 2006

Posts: 19,878
Thanks: 1835

Quote:
Originally Posted by Denis View Post
Why can't it be a simple "pause(?)" command,
like my beloved UBasic
I haven't checked, but I suspect that a coder who preferred the word "pause" could write their own macro with that name.
Thanks from Denis
skipjack is offline  
July 29th, 2018, 05:59 AM   #7
Math Team
 
Joined: Oct 2011
From: Ottawa Ontario, Canada

Posts: 13,468
Thanks: 949

Quote:
Originally Posted by skipjack View Post
I haven't checked, but I suspect that a coder who preferred the word "pause" could write their own macro with that name.
You mean "their own subroutine"?
Denis is offline  
July 29th, 2018, 06:23 AM   #8
Global Moderator
 
greg1313's Avatar
 
Joined: Oct 2008
From: London, Ontario, Canada - The Forest City

Posts: 7,881
Thanks: 1088

Math Focus: Elementary mathematics and beyond
The C Preprocessor: Macros
Thanks from Denis
greg1313 is offline  
July 29th, 2018, 09:58 AM   #9
Senior Member
 
romsek's Avatar
 
Joined: Sep 2015
From: USA

Posts: 2,172
Thanks: 1142

Quote:
Originally Posted by MathsLearner123 View Post
But the definition generally will be available in .c file but not sure. The declaration will be available in .h file i think.
in this particular case __delay_ms() turns out to be a macro, i.e. a symbol that is expanded to inline code by the pre-processor.

one would think it would be included in htc.h but apparently not.

OP if you are going to get into coding into any depth you had best get used to reading the documentation that comes with your compiler/development environment.

Last edited by skipjack; July 29th, 2018 at 10:06 AM.
romsek is online now  
July 29th, 2018, 10:01 AM   #10
Math Team
 
Joined: Oct 2011
From: Ottawa Ontario, Canada

Posts: 13,468
Thanks: 949

Quote:
Originally Posted by romsek View Post
OP if you are going to get into coding into any depth you had best get used to reading the documentation that comes with your complier/development environment.
....but that's too much work!
Denis is offline  
Reply

  My Math Forum > Science Forums > Computer Science

Tags
code, error



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is error in this code? integration Computer Science 4 March 31st, 2018 12:56 AM
Grey code for 25(10) error?; Need help fast please unistu Algebra 2 June 17th, 2016 12:31 AM
Maximum allowable probability of error for the (8, 4) Hamming Code jmomo Abstract Algebra 1 May 7th, 2014 07:52 AM
Pi Code+Phi code..please complete Keith742 Algebra 1 June 21st, 2009 07:09 PM
Code generation, probability of generating same code twice NateL Algebra 2 July 15th, 2008 08:07 PM





Copyright © 2018 My Math Forum. All rights reserved.