我目前正在使用 USS 接口(interface)在 MVS 上移植应用程序。我在编译(使用 C++ 编译器)以下程序时遇到问题:
#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 文档指出,想要使用套接字函数的人应该定义 _OE_SOCKETS
(如果是 C++,则定义 _XOPEN_SOURCE_EXTENDED
)。但是我有 undefined symbol 套接字:
$> 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.
一些调查让我认为我有一个损坏的 sys/socket.h 头文件,实际上这是该文件的摘录:
690: #ifndef _OE_SOCKETS /* must be __UU */
...
732: int socket (int, int, int);
...
780: #endif /* ifndef _OE_SOCKETS */
我觉得 #ifndef _OE_SOCKETS
应该是 #ifdef _OE_SOCKETS
。
有人可以向我证实吗?谢谢。
最后,uname 在我使用的盒子上给出:
$> uname -a
OS/390 S0W1 20.00 03 2094
最佳答案
再说一次,以防万一这对其他人有用。
我误读了文档。如果您使用 C 编译器定义 _OE_SOCKETS
但如果您使用 C++ 编译器则定义 _XOPEN_SOURCE_EXTENDED
但不能同时定义两者!
关于c++ - USS C++套接字编程和_OE_SOCKETS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1613167/