This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

binding c into C++ progs


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(...)'





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]