Skip to content

Preprocessor failure when include zlib.h after defining dllimport as nothing #1807

Open
@vadz

Description

Some code, such as deprecated, but still useful https://github.com/microsoft/cpprestsdk, define dllimport as nothing which results in a preprocessor error from clang when including zlib.h, which comes from zlib-ng on recent Fedora systems (mine is 41) later:

In file included from /usr/include/zlib.h:41:
/usr/include/zconf.h:72:120: error: too few arguments provided to function-like macro invocation
   72 | #if defined(ZLIB_DLL) && (defined(_WIN32) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport)))

This is, of course, due to the fact that __has_declspec_attribute(dllimport) becomes an invalid expression when dllimport expands to nothing.

It could be argued that it's cpprestsdk's own fault, but doing this worked for many years and still does on systems not using zlib-ng, so I think it would be nice to make it work with it too. I could make a PR fixing this, but it will be inevitably (as always when dealing with C preprocessor) ugly, so I'd like to know if it would be welcome first, before submitting it.

Please let me know what do you think!

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions