Jump to content
  • Advertisement
Sign in to follow this  
TheComet

Strange "read" and "write" functions in OIS

This topic is 1664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I decided to build OIS 1.3 from source, and can't figure out why it's not compiling.

http://sourceforge.net/projects/wgois/

 

I did the usual procedure with:

./bootstrap
./configure
make

And get the following error:

libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../includes -I../includes -g -O2 -I/usr/X11R6/include -I/home/alex/Documents/c++/dep/include -g -O2 -MT LinuxJoyStickEvents.lo -MD -MP -MF .deps/LinuxJoyStickEvents.Tpo -c ./linux/LinuxJoyStickEvents.cpp  -fPIC -DPIC -o .libs/LinuxJoyStickEvents.o
./linux/LinuxJoyStickEvents.cpp: In member function 'virtual void OIS::LinuxJoyStick::capture()':
./linux/LinuxJoyStickEvents.cpp:100:77: error: 'read' was not declared in this scope
   int ret = read(mJoyStick, &js, sizeof(struct input_event) * JOY_BUFFERSIZE);
                                                                             ^
./linux/LinuxJoyStickEvents.cpp: In static member function 'static OIS::JoyStickInfoList OIS::LinuxJoyStick::_scanJoys()':
./linux/LinuxJoyStickEvents.cpp:275:13: error: 'close' was not declared in this scope
     close(fd);
             ^
./linux/LinuxJoyStickEvents.cpp:283:12: error: 'close' was not declared in this scope
    close(fd);
            ^
./linux/LinuxJoyStickEvents.cpp: In static member function 'static void OIS::LinuxJoyStick::_clearJoys(OIS::JoyStickInfoList&)':
./linux/LinuxJoyStickEvents.cpp:294:20: error: 'close' was not declared in this scope
   close(i->joyFileD);
                    ^
make[1]: *** [LinuxJoyStickEvents.lo] Error 1
make[1]: Leaving directory `/home/alex/Documents/c++/packages/ois-v1-3/src'
make: *** [all-recursive] Error 1

The code in question is here:

        //We are in non blocking mode - we just read once, and try to fill up buffer
        input_event js[JOY_BUFFERSIZE];
        while(true)
        {
                int ret = read(mJoyStick, &js, sizeof(struct input_event) * JOY_BUFFERSIZE);
        if( ret < 0 )
                        break;

What on earth is this "read" function and where did it come from? There are counterpart "write" functions with the same signatures, and I don't have the faintest idea of where they even come from...

 

Any help?

 

Share this post


Link to post
Share on other sites
Advertisement

 read, write, and close are posix functions. 'man 2 read' in unix should bring up the man pages.

 

 From your compiler output it seems like the header files are not being included. Try including <unistd.h>, that may fix your problem.

Share this post


Link to post
Share on other sites


The code in question is here:

//We are in non blocking mode - we just read once, and try to fill up buffer
input_event js[JOY_BUFFERSIZE];
while(true)
{
int ret = read(mJoyStick, &js, sizeof(struct input_event) * JOY_BUFFERSIZE);
if( ret < 0 )
break;

It may just be me, but that looks like a buffer overflow.

Share this post


Link to post
Share on other sites

You can also get OIS 1.4 is available on GitHub (download the master branch). When I added OIS into my code about half a year ago I had to use this version as I had some problems (not related to the one you had) with 1.3.

Share this post


Link to post
Share on other sites

 


The code in question is here:

//We are in non blocking mode - we just read once, and try to fill up buffer
input_event js[JOY_BUFFERSIZE];
while(true)
{
int ret = read(mJoyStick, &js, sizeof(struct input_event) * JOY_BUFFERSIZE);
if( ret < 0 )
break;

It may just be me, but that looks like a buffer overflow.

 

Don't think so. read reads bytes and the array size is specified correctly.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!