By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

i am running a c code to respond to a circuit for controlling electrical appliance co

P: 1
hi
i am running the code with manGW on windows 8 and am getting error with the ouportb inthe int main() function below it my code and the specific error

CODE:

#include<dos.h>
#include<stdio.h>
#include<conio.h>

#define PORT 0x378
extern int x,X;

void gotoxy(short x, short y);

main()

{
char val=0,key=0;
char str1[]="ON ";
char str2[]="OFF";
char *str;

printf("Press the approriate number key to turn on/off devices:\n\n");
printf("Here Device1 is connected to D0 of parallel port and so on\n\n");
printf("Press \"x\" to quit\n\n");

gotoxy(x,X);
{
gotoxy(1,8);
printf("Device1:OFF Device2:OFF Device3:OFF Device4:OFF\n");
printf("Device5:OFF Device6:OFF Device7:OFF Device8:OFF");

}

while(key!='x' && key!='X')

{
gotoxy(x,X);
{
gotoxy(1,12);
printf("Value in hex sent to the port:");
key=getch();
switch(key){

case '1':

gotoxy(9,8);
val=(val&0x01)?(val&(~0x01)):val|0x01;
str=(val&0x01)?str1:str2;
printf("%s",str);
outportb(PORT,val);
gotoxy(1,13);
printf("%x",val);
break;

case '2':

gotoxy(21,8);
val=(val&0x02)?(val&(~0x02)):val|0x02;
str=(val&0x02)?str1:str2;
printf("%s",str);
outportb(PORT,val);
gotoxy(1,13);
printf("%x",val);
break;

case '3':

gotoxy(33,8);
val=(val&0x04)?(val&(~0x04)):val|0x04;
str=(val&0x04)?str1:str2;
printf("%s",str);
outportb(PORT,val);
gotoxy(1,13);
printf("%x",val);
break;

case '4':

gotoxy(45,8);
val=(val&0x08)?(val&(~0x08)):val|0x08;
str=(val&0x08)?str1:str2;
printf("%s",str);
outportb(PORT,val);
gotoxy(1,13);
printf("%x",val);
break;

case '5':

gotoxy(9,9);
val=(val&0x10)?(val&(~0x10)):val|0x10;
str=(val&0x10)?str1:str2;
printf("%s",str);
outportb(PORT,val);
gotoxy(1,13);
printf("%x",val);
break;

case '6':

gotoxy(21,9);
val=(val&0x20)?(val&(~0x20)):val|0x20;
str=(val&0x20)?str1:str2;
printf("%s",str);
outportb(PORT,val);
gotoxy(1,13);
printf("%x",val);
break;

case '7':

gotoxy(33,9);
val=(val&0x40)?(val&(~0x40)):val|0x40;
str=(val&0x40)?str1:str2;
printf("%s",str);
outportb(PORT,val);
gotoxy(1,13);
printf("%x",val);
break;

case '8':
gotoxy(45,9);
val=(val&0x80)?(val&(~0x80)):val|0x80;
str=(val&0x80)?str1:str2;
printf("%s",str);
outportb(PORT,val);
gotoxy(1,13);
printf("%x",(unsigned char)val);
break; }

}
}
}

THE ERROR:
In functiion 'int main()':
52:19: error: 'outportb ' was not declared in this scope outportb<port,val>

PLEASE ANY HELP...
May 27 '16 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
Where is the outportb function defined? It is called from several places but there is no function definition or function prototype so the compiler doesn't know if this is a good call or not.
May 27 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.