Skip to content

opj_includes.h shouldn't define __attribute__ #727

@nico

Description

@nico

opj_includes.h has this snippet:

/* Ignore GCC attributes if this is not GCC */
#ifndef __GNUC__
    #define __attribute__(x) /* __attribute__(x) */
#endif

That's not valid, things starting with two underscores are reserved for the implementation and shouldn't be redefined. In practice, it's even actively harmful: When building openjpeg with clang-cl, __GNUC__ isn't defined, so __attribute__ gets defined to nothing, and then the same file includes <intrin.h> a bit futher down. clang-cl's intrin.h header uses __attribute__ internally, and since it's included after this redefine, clang-cl gets very confused.

One approach would be to do

#ifndef __GNUC__
  #define ATTRIB(x) __attribute__(x)
#else
  #define ATTRIB(x)
#endif

And then use ATTRIB everywhere -- but from what I can tell, all uses of __attribute__ are already guarded by other diffs and just deleting these 4 lines should probably be fine too.

(This blocks https://crbug.com/592745)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions