Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

can anyone make this correct for me

Status
Not open for further replies.

mformazhar1980

Junior Member level 1
Joined
Mar 23, 2009
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,436
dividend+((divisor) >> 1

hi i have this small code and i am trying to compile it on https://www.delorie.com/djgpp/compile/ but find myself unlucky
can any body tell me why is it happening and what these errors mean
cc1: warnings being treated as errors
/tmp/http.13856.c: In function `main':
/tmp/http.13856.c:75: warning: control reaches end of non-void function

my code is as follows



#include <stdio.h>
#include <math.h>
#define DIV(Dividend,Divisor) (((Dividend+((Divisor) >> 1))/(Divisor)))

int Ret_Val=0;


unsigned int Hi_Lim = 652;
unsigned int Lo_Lim = 155;

unsigned int Ref_Val_Hi = 475;
unsigned int Ref_Val_Lo = 372;
unsigned int Value = 0;
unsigned int Mask = 0;

int main(void)

{
printf("Enter a value between 155 to 652=");
scanf("%d",&value);

if((Value > Hi_Lim) || (Value < Lo_Lim))
{

Ret_Val = 229;
printf("error\n");

}
else
{

if((Value > Ref_Val_Lo) && ( Value < Ref_Val_Hi))
{ {
Ret_Val = 0;
printf("0x00 \n");
}

if(Value < Ref_Val_Lo)
{
Value -= Ref_Val_Lo;
Value >>= 1;
Value = DIV(Value,100);
Mask |= 128;
printf("value1= %d \n",Value);
printf("mask1= %d \n",Mask);

}

if(Value > Ref_Val_Hi)
{
Value -= Ref_Val_Hi;
Value >>= 1;
Value = DIV(Value,100);
Mask = 0;
printf("value2= %d\n",Value);
printf("mask2= %d \n",Mask);
}
}
Ret_Val |= Mask;
printf("value1= %d ",Ret_Val);
return 0;
}
}


looking forward if some one help me trying to correct this code
thanks
regards
 

if((value > hi_lim) || (value < lo_lim))

Hi,
Your main, although declared int, doesn't return a value on every execution path (the true path of if).
Just put a return 1; (or whatever value you want) before the last closing bracket in your program, like this:
Code:
int main(void)
{
   /* ... your code here ... */
   return 1;
}

Arthur

PS: find the corrected source in the attached file
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top