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

#define of OS breaks #pragma argument in subsequent header file includes #15455

Closed
jonrumsey opened this issue Oct 30, 2024 · 0 comments
Closed

Comments

@jonrumsey
Copy link
Contributor

I did this

Whilst developing some code to call the platform APIs on OS/400 to seed a PRNG;
https://www.ibm.com/docs/en/i/7.5?topic=ssw_ibm_i_75/apis/qc3addprngseed.html
These calls fail at runtime with MCH3601 exceptions, this only occurs when first including curl header files.

I expected the following

To be able to include curl headers before or after unrelated header files.

Many OS/400 system header files use pragmas to control how pointers are passed to APIs
https://www.ibm.com/docs/en/i/7.5?topic=descriptions-argument

Unfortunately the platform specific headers in curl (e.g. lib/config-os400.h) define "OS";

/* Define cpu-machine-OS */
#ifndef OS
#define OS "OS/400"
#endif

This gets expanded by the preprocessor and breaks any pragma that uses OS;

    63       |    #pragma argument (Qc3AddPRNGSeed,OS,nowiden)                                                  |  37415   158
    63       +    #pragma argument (Qc3AddPRNGSeed,"OS/400",nowiden)                                            +  37415   158
 ===========> .....................................a............................................................              
 *=WARNING=========> a - CZM0224  Incorrect pragma ignored.                                                                   
    64       |    void Qc3AddPRNGSeed                                                                           |  37416   158
    65       |                    (char *        , /* Seed data                  */                             |  37417   158
    66       |                     unsigned int  , /* Seed length                */                             |  37418   158
    67       |                     void *       ); /* Error Code                 */                             |  37419   158

This impacts any OS/400 headers that are included after curl header files, this can be worked around by including curl headers last or by undefining "OS" before including other headers. A better fix would be to apply a 'CURL_' prefix to the define i.e. 'CURL_OS' so that a string literal is not expanded incorrectly in place of OS.

curl/libcurl version

curl 8.10.1

operating system

OS/400 V7R4M0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant