Error Definition Of Is Not In Namespace Enclosing - Fpermissive
download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript). Home Qt Development General and Desktop [Solved] definition of ... is not in namespace enclosing ... - Why? [Solved] definition of ... is not in namespace enclosing ... - Why? This topic has been deleted. Only users with topic management privileges can see it. StephanWoebbeking last edited by Hi! I am trying to reuse a small application for some different behavior. So far it's not much more than some easy serial communication so I was relying on the Qt Terminal demo. The reused application works fine, so I copied that, moved it to a different folder and adjusted the project file. It opens fine, then I removed much stuff I think I don't need. But now I get this error: @ Fehler: definition of 'MainWindow::MainWindow(QWidget*)' is not in namespace enclosing 'MainWindow' [-fpermissive] MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { @ MainWindow is the name I gave to - have a guess ;) - the main window. The constructor is defined as this: @ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setWindowTitle( windowTitle() + Constants::STR_SPACE + Constants::VERSION ); setWindowIcon( QIcon( Constants::ICON_PATH ) ); ... @ The header file looks like this: @ #include #include #include #include #include #include "ServiceTools_Shared_Qt/Component/autostatemachine.h" QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE class SettingsDialog; class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void openSerialPort(); ... @ I have no idea what this compiler error is trying to tell me? Can anyone point me to the right direction? BTW: I am pretty new to Qt, so I hope the question is not to dull? ;) Thanks a lot & Regards, Stephan Wöbbeking Reply Quote 0 Chris Kawa Moderators last edited by As you can see there's this forward declaration in your header: @ namespace Ui
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Compile error when defining a member function, but only in GCC up vote 11 down vote favorite 1 The following program compiles without errors with MSVS, clang and GCC: class A; namespace Y https://forum.qt.io/topic/47558/solved-definition-of-is-not-in-namespace-enclosing-why { using ::A; class A {}; } int main() {} Now let's define a member function. Now it still compiles with MSVS and clang, but not with GCC: class A; namespace Y { using ::A; class A { void f() {} }; } int main() {} GCC gives the following error message: prog.cc:5:22: error: definition of 'void A::f()' is not in namespace enclosing 'A' [-fpermissive] Why is that? Is this a bug in GCC? If the second version of the http://stackoverflow.com/questions/31232186/compile-error-when-defining-a-member-function-but-only-in-gcc program violates a rule of the c++ standard, what rule does it violate and why doesn't MSVS and clang give a diagnostic message for that violation? Is this a case of an ambiguity of the c++ standard? From the error message it looks like GCC incorrectly thinks we have a violation of the following rule: http://eel.is/c++draft/class.mfct#2 "A member function definition that appears outside of the class definition shall appear in a namespace scope enclosing the class definition." We do not have a violation of this rule since the member function definition is inside the class definition. My theory is that GCC confuses the declaration class A; in the global namespace with the class definition class A { ... } in the namespace Y. I think we have a bug in GCC. With GCC they declare the same entity. This can be seen by observing that in the first version of the program it possible to use ::A as a complete type in main when compiling with GCC. Same for MSVS. With Clang however they declare different entities. This difference may be because of an ambiguity in the c++ standard. Regardless of such an ambiguity we are clearly not violating http://eel.is/c++draft/class.mfct#2 . That rule is very clear. Related question: Class declaration in same scope as using declaration compiles in GCC but not MSVS c++ gcc language-lawyer using-declaration share|improve this question edited Jul 5 '15 at 18:56 asked Jul 5
warnings vs. errors From: Volker Reichelt To: gcc at gcc dot gnu dot org Date: Wed, 11 Jun 2008 16:12:18 +0200 (CEST) https://gcc.gnu.org/ml/gcc/2008-06/msg00269.html Subject: C++ warnings vs. errors Hi, since Manuel's patch http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00962.html a lot of C++ code is now accepted on mainline (when compiling without special flags like -fpermissive and -pedantic), https://bugs.debian.org/356233 that used to be rejected. Instead of getting closer to the standard we get away from it, which is a bad idea IMHO - especially since the standard should error definition be widely adopted by now, given that it's about 10 years old. So here's a collection of some warnings that I'd rather see as errors: * Scopes in for-loops: void foo() { for (int i=0; i<10; ++i) {} i = 0; } warn.cc: In function 'void foo()': warn.cc:4: warning: name lookup of 'i' changed for new ISO error definition of 'for' scoping warn.cc:3: warning: using obsolete binding at 'i' Btw, because the compiler tries to be smart to track new scoping and old scoping at once it rejects valid code, accepts invalid code and even generates wrong code in some cases (see PR10852). * Declaration with no type: foo() {} warn.cc:1: warning: ISO C++ forbids declaration of 'foo' with no type Or even worse IMHO: struct A { i; }; warn.cc:3: warning: ISO C++ forbids declaration of 'i' with no type * Invalid use of 'template': struct A { static void foo(); }; template void bar() { A::template foo(); } warn.cc: In function 'void bar()': warn.cc:8: warning: 'A::foo()' is not a template Btw, I don't know why we should accept this even with -fpermissive. * Using 'struct' for a union: union A {}; struct A a; warn.cc:2: warning: 'struct' tag used in naming 'union A' * Static members of local classes: void foo() { struct A { static int i; }; } warn.cc: In function 'void foo()': warn.cc:5: warning: local class
Martin Michlmayr Date: Fri, 10 Mar 2006 15:48:40 UTC Severity: important Tags: patch Found in version beast/0.6.6-4 Fixed in version beast/0.6.6-5 Done: Sam Hocevar (Debian packages) Bug is archived. No further changes may be made. Toggle useless messagesView this report as an mbox folder, status mbox, maintainer mbox Report forwarded to debian-bugs-dist@lists.debian.org, Sam Hocevar (Debian packages) : Bug#356233; Package beast. Full text and rfc822 format available. Acknowledgement sent to Martin Michlmayr : New Bug report received and forwarded. Copy sent to Sam Hocevar (Debian packages) . Full text and rfc822 format available. Message #5 received at submit@bugs.debian.org (full text, mbox, reply): From: Martin Michlmayr To: submit@bugs.debian.org Subject: FTBFS with G++ 4.1: error: definition of ... not in namespace enclosing Date: Fri, 10 Mar 2006 15:42:13 +0000 Package: beast Version: 0.6.6-4 Severity: important Your package fails to build with G++ 4.1. I'm filing this bug as important for now, but when 4.1 will be the default compiler in unstable (probably in a few weeks) I'll upgrade this to serious. > Automatic build of beast_0.6.6-4 on bigsur by sbuild/mips 1.80 .... > mips-linux-gnu-g++ -DG_LOG_DOMAIN=\"SFI\" -DG_DISABLE_CONST_RETURNS -I.. -I.. -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall -g -O3 -g -DG_ENABLE_DEBUG -Wdeprecated -Wno-cast-qual -pipe -ftracer -finline-functions -fno-keep-static-consts -fmessage-length=80 -c sfidl-parser.cc > sfidl-parser.cc:179: error: definition of 'bool Sfidl::Parser::isChoice(const > std::string&)' is not in namespace enclosing 'Sfidl::Parser' > sfidl-parser.cc:185: error: definition of 'bool Sfidl::Parser::isSequence(const > std::string&)' is not in namespace enclosing 'Sfidl::Parser' > sfidl-parser.cc:191: error: definition of 'bool Sfidl::Parser::isRecord(const > std::string&)' is not i