Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with select( )

Status
Not open for further replies.

huskers

Programmer
Jan 29, 2002
75
US
When i am compiling on linux box with the following code:

long n;
n=select((1L<< 16) + 8L*BITS(int),&fds,NULL,NULL,NULL);

I am getting error: parse error before &quot;int&quot;....am i doing something wrong...the same code works fine on AIX.

thanks.
 
> (1L<< 16) + 8L*BITS(int),
1. (int) looks like it should be a cast, but casts prefix the expression, not postfix them
So perhaps
(1L<< 16) + 8L*(int)BITS,

2. The first parameter is supposed to be the number of fds to check, but this is one massive number - (1<<16) is like over 65000.
Does your 'fds' structure have this many entries?

--
 
To me, BITS looks like a macro should probably be defined as:

Code:
#define BITS(type)    (sizeof(type) * 8)

However, that doesn't look like something appropriate to put in the first value of a select() call. You're supposed to put the maximum fd in any of the FD_SETs you pass to it, plus one.

-
 
From the code snippette, it seems Azimuth0 is right in the definition od BITS.

I think the problem is in the first argument only.
(1L<< 16) + 8L*BITS(int)

This is a huge number. I dont think that any OS allows so many open FDs. HP-Unix allows 2K. And this number is more than 64K.

Maybe you can post some more related code for finding details about the error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top