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

Constexpr redeclaration #51

Open
StylishTriangles opened this issue Apr 16, 2019 · 2 comments
Open

Constexpr redeclaration #51

StylishTriangles opened this issue Apr 16, 2019 · 2 comments

Comments

@StylishTriangles
Copy link

This breaks my build so much. Please don't redeclare C++ keywords like that.

#define constexpr static const

/usr/include/c++/8/bits/algorithmfwd.h:370:5: error: redeclaration ‘const _Tp& std::max(const _Tp&, const _Tp&)’ differs in ‘constexpr’ from previous declaration
     max(const _Tp&, const _Tp&);
     ^~~
In file included from /usr/include/c++/8/bits/char_traits.h:39,
                 from /usr/include/c++/8/string:40,
                 from /usr/include/c++/8/stdexcept:39,
                 from /usr/include/c++/8/system_error:41,
                 from /usr/include/c++/8/bits/fs_fwd.h:35,
                 from /usr/include/c++/8/filesystem:36,
                 from orion/raytracer.cpp:1:
/usr/include/c++/8/bits/stl_algobase.h:219:5: note: previous declaration ‘constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
     max(const _Tp& __a, const _Tp& __b)
     ^~~
In file included from /usr/include/c++/8/bits/stl_algo.h:60,
                 from /usr/include/c++/8/algorithm:62,
                 from /usr/local/include/assimp/matrix3x3.inl:54,
                 from /usr/local/include/assimp/types.h:515,
                 from /usr/local/include/assimp/Importer.hpp:55,
                 from ./orion/model.hpp:7,
                 from ./orion/raytracer.hpp:9,
                 from orion/raytracer.cpp:7:
@PeterZhizhin
Copy link

I'd like to say that there is more than constexpr. explicit and noexcept are also redefined.

#ifndef constexpr
#define constexpr static const
#endif

#ifndef explicit
#define explicit
#endif

#ifndef noexcept
#define noexcept
#endif

@Tymon13
Copy link

Tymon13 commented Apr 9, 2022

I see this library is not really maintained, but let me leave some comments for anyone who finds this and needs to fix it for themselves. #ifdef constexpr most likely doesn't work, I don't know a compiler that defines this keyword as macros. constexpr semantics couldn't be expressed in C++ without direct compiler support, it wouldn't make sense anyway.

To properly test for C++11 features, check value of __cplusplus macro (since noexcept has no feature test macro associated):

#if __cplusplus < 201103L
#define constexpr const static
#define noexcept
//nothing for explicit, it has been in the language since C++98
#endif

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

3 participants