manipulating LPT port Dev C++

M

Thread Starter

Mark

problems with dev c++.

Trying to manipulate the LPT port (0x378), but always the same problem.using win98.

below you find the easy source code, but it doesn't work and always the same error

`_outp' undeclared (first use this function)
--------------------------------------------
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <dos.h>
using namespace std;

int main()
{
int y=5;

_outp(0x378,y);

return 0;
}
-----------------------------------
Thanks for helping me out.
 
Hello Mark;

First, From the error, it looks like you may be missing a header file... and therefore the compiler is not seeing the library routines that actually contain the code for talking to the ports. This could be simply an omission of path as to where to find the files or the file(S) missing.
Other possible problems could be compiler settings

Second, even if the program compiles, it still will likely not work; but since I don't really know your environment, I can't say for sure, but here is why!

Well, the thing is win98+ virtualizes all the hardware in your PC and therefore, you can't control it directly.You need to write what is called a VXD or activeX Control to do that. What you need is code for calling the windows API. Look at it study it etc... This is required in other to talk to hardware under windows in C/C++.

An alternative way is to use a tool like MSVB or labwindows or an assembler to write the code; or at least the portion that talks to hardware. The reason this is easy is that these environment have components which allow easy acess to hardware API without having to write complicated code yourself. Plenty of commercial tool exist(Vxtools ?), some even free that allow you to easily create a stub to talk to hardware or generate code that you can include in your C/C++ code... Do a search on the web...

Walt Njuh
Akume Tech
 
I had a similar problem with Dev C++.

By saving my program as a C program (ie program_name.c) rather than as a C++ (ie program_name.cpp or whatever) I was able to get a simple Dev C++ program to write to LPT1 and flash some LED's, under Win 98. The same program will NOT work when saved as a C++ program. Part of the issue is because of C++ and its requirement to declare all functions used within the program. This is usually done just after your #include statements.

The previous reply is not correct about Win 98, but is correct for all version of Windoz AFTER Win 98.
 
Top