On Sun, Jan 22, 2006 at 03:14:50AM +0100, Bc. Radek Krejca wrote:
| Hello,
|
|   I very bad in C language and I have following program written for
|   Linux. I need to change this source for working on bsd could you
|   help me? This programm shlould control LED on lpt port.
|
| file pokus.c
| ----------------------------
| #include <stdio.h>
| #include <stdlib.h>
| #include <unistd.h>
| #include <sys/io.h>
| #define base 0x378 /* adresa paralelneho portu*/
| main(int argc, char **argv)
| {
| int value;
| if (argc!=2)
| fprintf(stderr, "Bad number of arguments.\n"), exit(1);
| if (sscanf(argv[1],"%i",&value)!=1)
| fprintf(stderr, "Argument isnt a number.\n"), exit(1);
| if ((value<0) || (value>255))
| fprintf(stderr, "Bad range\n"),
| exit(1);
| if (ioperm(base,1,1))
| fprintf(stderr, "Port doesnt exists on address %x\n", base),
| exit(1);
| outb((unsigned char)value, base);
| }
| -----------------------------
|
|
| I switched #include <sys/io.h> to #include <i386/pio.h> , but
| complilation with command # gcc -O pokus.c -o pokus
| fails.
|
| # gcc -O pokus.c -o pokus
| pokus.c: In function `main':
| pokus.c:18: warning: comparison is always true due to limited range of data
type
| pokus.c:18: warning: large integer implicitly truncated to unsigned type
| pokus.c:18: warning: large integer implicitly truncated to unsigned type
| /tmp//ccTe4507.o(.text+0x81): In function `main':
| : undefined reference to `ioperm'
| collect2: ld returned 1 exit status

First of all, this is not the complete source code to your program. Or
at least, not to the source that gave you the above errormessage.
There is no comparison on line 18 of the code you included. You may
want to check in to the warnings gcc gives you concerning line 18.

The errormessage says it all, "undefined reference to `ioperm'". This
is a linux function, on OpenBSD I suggest you take a look at
i386_get_ioperm(2) and the manual pages it references.

Always be very carefull writing such programs as you can completely
crash your machine doing your own IO, including losing all your data.
Also remember that you need elevated privileges to run such code.

Good luck.

Paul 'WEiRD' de Weerd

--
>++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
                 http://www.weirdnet.nl/

[demime 1.01d removed an attachment of type application/pgp-signature]

Reply via email to