Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS400 compiling a C++ program with the include curl.h fails. #10305

Closed
johnsherrill opened this issue Jan 16, 2023 · 4 comments
Closed

OS400 compiling a C++ program with the include curl.h fails. #10305

johnsherrill opened this issue Jan 16, 2023 · 4 comments
Labels

Comments

@johnsherrill
Copy link

johnsherrill commented Jan 16, 2023

The include curl.h includes systems.h
systems.h has this section for OS400

#elif defined(__OS400__)
#  if defined(__ILEC400__)
#    define CURL_TYPEOF_CURL_OFF_T     long long
#    define CURL_FORMAT_CURL_OFF_T     "lld"
#    define CURL_FORMAT_CURL_OFF_TU    "llu"
#    define CURL_SUFFIX_CURL_OFF_T     LL
#    define CURL_SUFFIX_CURL_OFF_TU    ULL
#    define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
#    define CURL_PULL_SYS_TYPES_H      1
#    define CURL_PULL_SYS_SOCKET_H     1
#  endif           

__ILEC400__ is only defined if using the C compiler
If you what to use curl in C++ code the compile fails
since CURL_TYPEOF_CURL_OFF_T is not defined so the below code is not used

/* Data type definition of curl_off_t. */

#ifdef CURL_TYPEOF_CURL_OFF_T
  typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
#endif                           

which causes errors in curl.h since curl_off_t is not defined.

adding || (__cplusplus) to the "#if defined(__ILEC400) line fixes the problem.

@jay
Copy link
Member

jay commented Jan 16, 2023

adding || (__cplusplus) to the "#if defined(__ILEC400) line fixes the problem.

@jonrumsey does this seem right to you?

@jay jay added the build label Jan 16, 2023
@johnsherrill
Copy link
Author

I can state with __cplusplus added I can compile C++ that includes curl.h. Without it fails with curl_off_t not defined.

@jonrumsey
Copy link
Contributor

Yes, #if defined(__ILEC400__) || defined(__cplusplus) would define those types for both C & C++ compilers, however you'll only be including the systems.h header when compiling a C/C++ module so just removing the check for __ILEC400__ and leaving this under the __OS400__ check is equally valid and perhaps a little clearer.

@johnsherrill
Copy link
Author

I agree that would be cleaner.

jay added a commit to jay/curl that referenced this issue Jan 20, 2023
Prior to this change the OS400 types were only defined when __ILEC400__.
That symbol is only defined by IBM's C compiler and not their C++
compiler, which led to missing types when users would compile a C++
application.

Assisted-by: Jon Rumsey
Reported-by: John Sherrill

Fixes curl#10305
Closes #xxxx
@jay jay closed this as completed in 3feb6b4 Jan 21, 2023
bch pushed a commit to bch/curl that referenced this issue Jul 19, 2023
Prior to this change the OS400 types were only defined when __ILEC400__.
That symbol is only defined by IBM's C compiler and not their C++
compiler, which led to missing types when users on OS400 would compile a
C++ application that included curl.

The IBM C and C++ compilers are the only native compilers on the
platform.

Assisted-by: Jon Rumsey
Reported-by: John Sherrill

Fixes curl#10305
Closes curl#10329
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants