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

libco #defines conflict with Qt #15

Closed
lanwatch opened this issue Jan 20, 2021 · 4 comments
Closed

libco #defines conflict with Qt #15

lanwatch opened this issue Jan 20, 2021 · 4 comments

Comments

@lanwatch
Copy link

These 2 symbols are colliding, is there a "nice" way to put libco in its own namespace? (I guess not since it's C89)

/opt/HIP-CPU/external/libco/settings.h:99: note: macro "section" defined here
   99 |   #define section(name) __attribute__((section(#name)))
      |
In file included from /opt/Qt/5.12.6/gcc_64/include/QtCore/QString:1,
                 from ../modules/Writer.cpp:13:
/opt/Qt/5.12.6/gcc_64/include/QtCore/qstring.h:376:104: error: macro "section" passed 4 arguments, but takes just 1
  376 |     QString section(const QString &in_sep, int start, int end = -1, SectionFlags flags = SectionDefault) const;
@AlexVlx
Copy link
Collaborator

AlexVlx commented Jan 20, 2021

Thank you for filing this. Since that's a macro, namespacing won't really help much. Also, we're clients of libco so modifying it would be a last resort (although possibly desirable, ultimately, since this is a consequence of us using it as a header only / all inline library, which is a modification in and of itself). What I think can be done is something like this:

#if defined(section)
#undef section
#endif
#include <whatever_qt_file_leads_to_qstring.h_being_included>

@lanwatch
Copy link
Author

Hi Alex,

how about

#include "../../../../external/libco/libco.h"
#undef section

in fiber.hpp:24 ?

Works for me :)

@AlexVlx
Copy link
Collaborator

AlexVlx commented Jan 26, 2021

@franjesus yup, that works too and is cleaner, but I've convinced myself that having a macro squat on such a common name is a faux pas, so I'll bite the bullet and just rename the macro to LIBCO_SECTION (other libco macros are similarly "namespaced", to it should be possible to have this upstreamed eventually).

@lanwatch
Copy link
Author

Thanks! makes sense

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

No branches or pull requests

2 participants