How to use the C socket API in C++ on z/OS

前端 未结 9 1014
闹比i
闹比i 2021-02-01 11:23

I\'m having issues getting the C sockets API to work properly in C++ on z/OS.

Although I am including sys/socket.h, I still get compile time errors telling m

9条回答
  •  一个人的身影
    2021-02-01 12:01

    @Jax: The extern "C" thing matters, very very much. If a header file doesn't have one, then (unless it's a C++-only header file), you would have to enclose your #include with it:

    extern "C" {
    #include 
    // include other similarly non-compliant header files
    }
    

    Basically, anytime where a C++ program wants to link to C-based facilities, the extern "C" is vital. In practical terms, it means that the names used in external references will not be mangled, like normal C++ names would. Reference.

提交回复
热议问题