tags:

views:

85

answers:

1

Hi there,

I'm currently porting an app on MVS using the USS interface. I'm facing an issue compiling (using c++ compiler) the following program:

#define _XOPEN_SOURCE_EXTENDED 1
#define _OE_SOCKETS
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

int main() {
  struct in_addr add;
  int sd = socket(AF_INET, SOCK_STREAM, 0);
  inet_ntoa(add);
  return 0;
}

IBM docs states that the one who want to use sockets functions should define _OE_SOCKETS (and _XOPEN_SOURCE_EXTENDED if it's C++). But I'm having undefined symbol socket:

$> c++ test.cpp
"./test.cpp", line 10.12: CCN5274 (S) The name lookup for "socket" did not find a declaration.
CCN0793(I) Compilation failed for file ./test.cpp.  Object file not created.
FSUM3065 The COMPILE step ended with return code 12.
FSUM3017 Could not compile test.cpp. Correct the errors and try again.

A bit of investigation make me think that I have a corrupted sys/socket.h header file, indeed here is an extract of this file:

690:     #ifndef _OE_SOCKETS   /* must be __UU */
...
732:          int     socket      (int, int, int);
...
780:      #endif    /* ifndef _OE_SOCKETS */

I feel like the #ifndef _OE_SOCKETS should be an #ifdef _OE_SOCKETS.

Can anyone confirm that to me? thanks.

Last, uname gives on the box I'm using:

$> uname -a
OS/390 S0W1 20.00 03 2094
A: 

Me again, just in case this would be useful to someone else.

I misread the doc. If your using C compiler define _OE_SOCKETS but if your using a C++ compiler then define _XOPEN_SOURCE_EXTENDED but not both!

sylvain benilan