This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
binding c into C++ progs
- To: <help-gcc at gnu dot org>
- Subject: binding c into C++ progs
- From: "Andreas Frey" <andreas dot frey at student dot uni-tuebingen dot de>
- Date: Sat, 15 Apr 2000 13:33:12 +0200
Hi,
I have problems using some c system calls under linux (2.2.14). e. g.
usleep() and ioperm() in a c++ program.
i get clean compiles with gcc (ver 2.95.2) and c sources, but not with cpp
sorces that are binding the c headers for the system calls.
hope you can help me.
thanks a lot!
Andreas Frey
**main.c **********(gcc -O1 -o main main.c **********clean
compile*************
***********************************************************************
#include <asm/io.h>
#include <asm/unistd.h>
int main(int argc, char *argv[])
{
int c=1, port = 0x278;
printf("ioperm Status: %i\n", // aquire port
ioperm( port, 3, 1) );
do { // test port
printf("%i\n", c);
outb(c,port);
usleep(100000);
} while ( (c*=2)%512!=0 );
return 1;
}
**main.cpp*****dirty compile, see
below****************************************
***********************************************************************
#include <stdio.h> // for printf
extern "C" { // <-- strange: does nothing
#include <asm/io.h> // for outb()
#include <asm/unistd.h> // for ioperm(), usleep()
}
int main(int argc, char *argv[])
{
int c=1, port = 0x278;
printf("ioperm Status: %i\n", // aquire port
ioperm( port, 3, 1) );
do { // test port
printf("%i\n", c);
outb(c,port);
usleep(100000);
} while ( (c*=2)%512!=0 );
return 1;
}
************************************************************************
***>c++ -O1 -o main main.cpp
***>main.cpp: In function `int main(int, char **)':
***>main.cpp:12: implicit declaration of function `int ioperm(...)'
***>main.cpp:17: implicit declaration of function `int usleep(...)'