Namespace variable bug ?

 

Why only classes and functions are allowed in namespaces unlike variables ?

namespace A {
 int x;
}
namespace B {
 int x;
}
 
ILoveBouldering:Why only classes and functions are allowed in namespaces unlike variables ?

I suggest you read the documentation again:

Namespaces

A namespace is a specially declared area, within which various IDs are defined: variables, functions, classes, etc. It is set using the namespace keyword:

namespace name of_space { 
  // list of function, class and variable definitions
}

 
Fernando Carreiro #:

I suggest you read the documentation again:

Namespaces

A namespace is a specially declared area, within which various IDs are defined: variables, functions, classes, etc. It is set using the namespace keyword:


I did many times, yet I can't figure it out, so if you can help me out I'll appreciate it
Thanks
 
ILoveBouldering #: I did many times, yet I can't figure it out, so if you can help me out I'll appreciate i. Thanks

Then please explain what the problem is, in more detail and some sample code to reproduce the problem. Your original post does not explain anything. All it is, is a simple question but no explanation and some code which does not demonstrate anything.

 
Fernando Carreiro #:

Then please explain what the problem is, in more detail and some sample code to reproduce the problem. Your original post does not explain anything. All it has s a simple question but no explanation and some code which does not demonstrate anything.

The code I wrote simply doesn't compile saying that the variable x was already defined
 
ILoveBouldering #: I did many times, yet I can't figure it out, so if you can help me out I'll appreciate it.

Ok, I see what you mean. The compiler throws an error " 'x' - variable already defined ".

Lets wait for some one else to confirm this, and whether this is related to the current build or it happens on all builds.

EDIT: I'm going to downgrade my MetaEditor to see if it happens in older builds.

 
Fernando Carreiro #:

Ok, I see what you mean. The compiler throws an error " 'x' - variable already defined ".

Lets wait for some one else to confirm this, and whether this is related to the current build or it happens on all builds.

EDIT: I'm going to downgrade my MetaEditor to see if it happens in older builds.

Thank you man
 

Ok! I tested it against several past builds and all of them throw the same error.

So, I am going to assume this is a bug, and ask @Alain Verleyen to confirm this, just in case we are the ones not understanding it correctly, and ask him to communicate it to the admins if possible.

 
Confirmed and reported.
 
Alain Verleyen #: Confirmed and reported.

🙏Thank you! Your efforts are much appreciated. 👍

 
Fernando Carreiro #:

🙏Thank you! Your efforts are much appreciated. 👍

Thank you