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

"namespace linux" clashes with GNU C++14 extensions #1946

Open
wflohry opened this issue Dec 22, 2017 · 6 comments
Open

"namespace linux" clashes with GNU C++14 extensions #1946

wflohry opened this issue Dec 22, 2017 · 6 comments
Labels

Comments

@wflohry
Copy link
Contributor

wflohry commented Dec 22, 2017

Using gcc 6.3.0, compiling with linux fails if "-std=gnu++14" is used. Compiling with "-std=c++14" works fine.

The GCC manual (see 2.2 C++ Language) says:

By default, GCC also provides some additional extensions to the C++ language that on rare occasions conflict with the C++ standard. The default, if no C++ language dialect options are given, is
-std=gnu++14.

Specifically, the lines referring to "namespace linux" cause the following error:

/root/.jenkins/cinder/include/cinder/linux/FreeTypeUtil.h:38:30: error: expected identifier before numeric constant
 namespace cinder { namespace linux { namespace ftutil {
                              ^
compilation terminated due to -Wfatal-errors.

To replicate, compile with "-std=gnu++14".
I was able to fix it by either:

  1. compiling with "-std=c++14" and not gnu++14, or
  2. replacing all uses of the namespace linux with ci_linux
@richardeakin
Copy link
Collaborator

So is linux made to be a reserved keyword when gnu++14 is used then? Does the compiler complain for other places where there is a namespace linux, like here? This seems pretty non-standard, but I don't see changing the name of that namespace to be a big deal (though I'd hope we could think of a good alternative within an underscore in it, for consistency).

@MikeGitb
Copy link
Contributor

Can't check, but sounds like linux is a macro in that mode.

@wflohry
Copy link
Contributor Author

wflohry commented Dec 23, 2017

Does the compiler complain for other places where there is a namespace linux, like here?

It seems that any use of namespace linux results in an error.

To test, I created a simple main.cpp file:

namespace cinder { namespace linux { } }
int main() { return 0; }

I tested with gcc 6.3.0 and gcc 7.2.0.

Running c++ main.cpp -std=gnu++14 or c++ main.cpp results in the error.

Running c++ main.cpp -std=c++14 doesn't result in the error.

@PetrosKataras
Copy link
Contributor

I m wondering why the GNU version is pulled in by default since -std=c++14 should be already explicitly set here .

@wflohry
Copy link
Contributor Author

wflohry commented Dec 24, 2017

It's not necessarily a problem with compiling Cinder itself, but using it in software that has the GNU++14 extensions. If namespace linux only appeared in Cinder's compiled files it wouldn't be a problem, but since it appears in the header files, it will clash with the GNU++14 extensions in software using it.

@MikeGitb
Copy link
Contributor

MikeGitb commented Feb 21, 2020

@richardeakin , @andrewfb : Is there any consensus to rename that namespace is this a won't fix and people just can't use cinder with -std=gnu++14 / gnu++17?

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

No branches or pull requests

4 participants