473,388 Members | 1,327 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Call to undefined function error

49
hi
i made program to control sevensegment but when i make debug
tell me call to undefined function inportb
Expand|Select|Wrap|Line Numbers
  1. #define Data 0x378
  2. #define Status Data+1
  3. #define Control Data+2
  4.  
  5. #include <dos.h>
  6. #include <conio.h>
  7. #include <stdio.h>
  8. #include <iostream.h>
  9.  
  10. void main(int n)
  11. {
  12.   int x;
  13.   do{
  14.      x=inportb(Status);
  15.      x= x&& 0x80;
  16.      }while(x!=0x80);
  17.  //  do{
  18.       if(kbhit()==1)
  19.       {
  20.        // int n;
  21.         switch(n)
  22.         {
  23.          case 0:
  24.          outportb(Data,0x40) ;
  25.          break ;
  26.          case 1:
  27.          outportb(Data,0x57);
  28.          break;
  29.           case 2:
  30.          outportb(Data,0x09);
  31.          break;
  32.           case 3:
  33.          outportb(Data,0x03);
  34.          break;
  35.           case 4:
  36.          outportb(Data,0x26);
  37.          break;
  38.           case 5:
  39.          outportb(Data,0x12);
  40.          break;
  41.           case 6:
  42.          outportb(Data,0x10);
  43.          break;
  44.           case 7:
  45.          outportb(Data,0x47);
  46.          break;
  47.           case 8:
  48.          outportb(Data,0x00);
  49.          break;
  50.           case 9:
  51.          outportb(Data,0x02);
  52.          break;
  53.          default: cout<< "this is wrong" ;
  54.          break;
  55.          }
  56.        }
  57.      else cout<<"do nothing";
  58.   //   }while
  59.   }
  60.  
Feb 2 '09 #1
22 8490
donbock
2,426 Expert 2GB
Header files <dos.h>, <conio.h>, and <streamio.h> are only available on certain platforms -- they are not part of Standard C. Are you sure they are available on your platform?

Functions inportb and outportb are only available on certain platforms -- they are not part of Standard C. Are you sure they are available on your platform? Your error message suggests that at least one of them wasn't available to the linker. You may need to specify an object library on the command line. The name of the necessary object library is platform-dependent.

By the way, what is your platform?

Header file <stdio.h> is part of Standard C; but header file <streamio.h> might be intended to refer to <streamio>, part of Standard C++. You really don't want to mix these together. Are you using C or C++?
Feb 2 '09 #2
newb16
687 512MB
Anyway, you can't write to io ports by address from win32 program, and from dos program on win2k and later. You need to find some driver that allows you to do it ( dlportio, giveio, etc ). And most of them don't work on vista.
Feb 2 '09 #3
Banfa
9,065 Expert Mod 8TB
and finally main should be either

int main()

or

int main(int argc, char **argp)

but not

void main(int n)
Feb 2 '09 #4
orked
49
I used Borland C++, so i can use iostream library
i want to know ,if i can use kbhit in c++or not but it need stdio.h library
Feb 2 '09 #5
orked
49
oh ,i forgot asking about dos ,my doctor told we can use it in c or c++ and two function (inportb&outportb) defined in it,why the program told "call to undefined function"
Feb 3 '09 #6
newb16
687 512MB
What part of the sentence in #6 is a question?

Nevertheless, open dos.h that your compiler includes and look if there are these functions declared.
Feb 3 '09 #7
orked
49
sorry ,can you tell me how i can open dos.h to show if functions defined in it or not
my question in #6 dos.h library found in c++ or not,and why is not defined my function if it is found
Feb 3 '09 #8
Banfa
9,065 Expert Mod 8TB
dos.h library is not in C++ because, as stated in #2 they are not part of the C++ standard. However they may be available on your platform. Your platform is the hardware/OS combination you are using.

You open dos.h in the same way you open any source file, locate it on your hard drive and use a text editor to open it.
Feb 3 '09 #9
orked
49
you mean i will find information about dos in class libraries guide in the program itself
Feb 3 '09 #10
Banfa
9,065 Expert Mod 8TB
No we mean open dos.h in a text editor and read it and understand what is being declared in it.
Feb 3 '09 #11
orked
49
i searched in the help of program ,i didn't find any thing about dos.h
where i can find this text editor
Feb 3 '09 #12
donbock
2,426 Expert 2GB
@orked
First, search your hard disk(s) for a file named "dos.h".
Second, take a look at that file. Use whatever editor you're most comfortable with -- the one you used to create fact.c, Notepad, whatever.

You're looking for function prototypes for inportb and outportb. Are they there at all? Are they conditionally compiled out?

You still haven't told us: what operating system are you using? Is it DOS or Windows or something else? What version of Windows? Are you editing and compiling on the same machine where the program is expected to run?
Feb 3 '09 #13
orked
49
i using windows xp sp2, i still test program , when the program run without error ,i will connect it with the circuit to make control on sevensegment
Feb 3 '09 #14
JosAH
11,448 Expert 8TB
@orked
Windows uses a 'hal', and 'Hardware Abstraction Layer' that forbids every user program to read/write the I/O ports directy; no chance your program will every work as it is now.

btw, the following line from your program most certainly doesn't do what you want it to do:

Expand|Select|Wrap|Line Numbers
  1. x= x&& 0x80;
  2.  
Better use the '&' operator instead.

kind regards,

Jos
Feb 3 '09 #15
orked
49
which OS the program run on it
Feb 3 '09 #16
newb16
687 512MB
@orked
If it is a question (it obviously isn't, y' know, that shift+slash at the end), I really don't understand what answer do you expect. If my answer #3 doesn't fit..
Feb 3 '09 #17
orked
49
@newb16
sorry i'am beginner in c++, so i can't understand what( dlportio, giveio) mean?
and i using windows xp not vista
Feb 3 '09 #18
donbock
2,426 Expert 2GB
You are trying to directly access the hardware. Windows XP doesn't let user programs do that. You would have to write and install a device driver. Frankly, beginners should simply not go there -- you could really mess up your computer.

If you are determined to proceed with this project, you should consider running on a simpler, safer platform such as DOS on a PC/104 card. There is a lot of busy work involved in getting such a system up and running; and you'll need cross-development tools.
Feb 3 '09 #19
newb16
687 512MB
@orked
It's a driver(s) for win2k/xp that may fit your needs for this task (access io ports from user program).
Feb 3 '09 #20
orked
49
@newb16
how can i use it because i must make my project control by pc and i must use parallel port
Feb 3 '09 #21
newb16
687 512MB
You are right, exactly.
Feb 3 '09 #22
orked
49
@newb16
you didnot tell me how can i use this drive
Feb 4 '09 #23

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

Similar topics

6
by: obi wan kenobi | last post by:
i've used the Amazon PHP api for several months now to pull amazon data into my affiliate site - but recently i'm starting to get "call to undefined function" errors " Fatal error: Call to...
4
by: gc | last post by:
I'm a PHP and MySQL newbie. I have a feeling a lot of you may have seen this before. I'm teaching myself PHP/MySQL and trying to setup a guestbook. I'm running latest versions of Apache, PHP and...
1
by: annie | last post by:
Can anyone point me in the right direction here? I've got this little image script <?php $im = ImageCreate(200,200); $white = ImageColorAllocate($im,oxFF,oxFF,oxFF); $black =...
1
by: franscescomoi | last post by:
Hi. On PHP 4.3.10 on Linux I try to: ------ $im = imagecreate(400, 30); $black = imagecolorallocate($im, 0, 0, 0); imagettftext($image, 20, -3, 10, 20, $black, 'Arial.ttf', 'Test'); ------- ...
1
by: muelli75 | last post by:
Hi! Im getting insane by solving a problem .... I try to define a function which uses a code-snippet from another file. My base are the codes from the great book "WebDataBase-Book by H....
8
by: Cruella DeVille | last post by:
I'm writing a class to handle reading/writing from/to files like this (shortened) lass FileIO{ private $filename; private $mode; private $filePointer; private $dictionary; public function...
11
by: Felix Kater | last post by:
Hi, I can compile and run this code (see below) which twice calls the function f, first with too less, second with too much arguments. But is it legal and free of memory leaks and other...
9
by: java | last post by:
Hey there, I just removed an elderly PHP4-Installation from my Windows-Box and installed PHP 5.2.1. I used the PHP4-Module as local batchfile- interpreter by E:\ersDHCP>php ./extractLog.php ...
1
by: maverick1911 | last post by:
Can any body help with the above error and how to fix it . here is the code refered to in the error Fatal error: Call to undefined function displayHeader() in C:\wamp\www\functions.php on line...
9
by: CryptiqueGuy | last post by:
Consider the variadic function with the following prototype: int foo(int num,...); Here 'num' specifies the number of arguments, and assume that all the arguments that should be passed to this...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.