?
Solved

null statement at the end of  namespace scope

Posted on 2002-04-30
17
Medium Priority
?
274 Views
Last Modified: 2010-04-02
namespace A
(
};

Is it an error to have a null statement at the end of a namespace scope, and if so, where in the standards does it defined this as an error?
0
Comment
Question by:Axter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +3
17 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6981845
Hmm - VC++ doesn't complain, g++ doesn't complain, and I cannot see any harm in doing that...
0
 
LVL 30

Author Comment

by:Axter
ID: 6981904
>>Hmm - VC++ doesn't complain, g++ doesn't complain, and I
>>cannot see any harm in doing that...

I don't see any harm in it either, and previously, I've never seen a compiler complain about it.
My problem is that I'm porting code to Unix platform, and I'm using stupid compiler that reports this as an error.

I've complain to the vendor of the compiler, and the vendor stated that the code was erroneous, and the compiler is correct to report this as an error.
His only referrence was the following newsgroup link:
http://groups.google.com/groups?q=namespace+semicolon+%22null+statement%22+g
0
 
LVL 32

Expert Comment

by:jhance
ID: 6981915
So when did newgroup postings become authoritative as a LRM?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 86

Expert Comment

by:jkr
ID: 6981917
The way I interpret the article is that

namespace A {
;
}

would be incorrect, as the namespace scope (strictly speaking) ends with the closing bracket...
0
 
LVL 86

Expert Comment

by:jkr
ID: 6981925
Just to add that neither VC++ nor g++ complain about

namespace A {
;
}

either...
0
 
LVL 30

Author Comment

by:Axter
ID: 6981964
Every compiler I've used always ignored null statement, ALMOST regardless of were it's located.

The section 6.2 of the C++ standard, states the following:
An expression statement with
the expression missing is called a null statement. [Note: Most statements are expression statements—
usually assignments or function calls. A null statement is useful to carry a label just before the } of a compound
statement and to supply a null body to an iteration statement such as a while statement (6.5.1). ]

Then section 6.2 states the following:
[Note: a declaration is a statement (6.7). ]

I interpret that as contridicting what the newsgroup link states.

Furthermore, I can not find any where in the standard where it states that a null statement is not allowed after a namespace scope.
0
 
LVL 30

Author Comment

by:Axter
ID: 6981984
>>So when did newgroup postings become authoritative as a >>LRM?
That's the first thing I said when I realized the link was a newsgroup link.
0
 
LVL 32

Expert Comment

by:jhance
ID: 6982008
You'd think they could at least refer to a specific item in the LRM.  Even if their INTERPRETATION of the standard is questionable, at least they could claim that their interpretation is reasonable.
0
 
LVL 4

Expert Comment

by:AssafLavie
ID: 6982709
The namespace definition in the std does not end with a semi colon therefor it's illegal. I find the simplest interpretation is usually the best.
0
 
LVL 4

Expert Comment

by:AssafLavie
ID: 6982713
ONOH, there's no restrictions on empty simple-declarations inside the translation unit... So one could argue that the semicolon is valid (although, I', fairly certain that it's not a null-statement but a null-declaration).
0
 
LVL 30

Author Comment

by:Axter
ID: 6983112
>>that it's not a null-statement but a null-declaration).

According to the standards, a declaration is a statement.  

Therefore, a null-declaration is a null-statement.
0
 
LVL 86

Expert Comment

by:jkr
ID: 6983953
BTW - the "null statement" is not part of the NS anyway (IMHO), as the namespace scope (strictly speaking) ends with the closing bracket...
0
 
LVL 30

Author Comment

by:Axter
ID: 6983987
jkr,
I'm not sure what you mean by NS?  Namespace??? Null-Statement???

I know that the null-statement is not needed.  What I'm trying to determine is if the standards prohibit a null-statement from been placed after a namespace.
0
 
LVL 86

Expert Comment

by:jkr
ID: 6984001
In this case, NS == NameSpace :o)
0
 
LVL 11

Expert Comment

by:griessh
ID: 7122235
Dear Axter

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to

     "refund the points and PAQ at zero points"

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 30

Author Comment

by:Axter
ID: 7122405
>>I think you forgot this question. I will ask Community
>>Support to close it unless you finalize it within 7 days.

I didn't forget it.  I just couldn't delete it.
The delete option is gone.
It seems that once someone post a comment, you no longer have the option to delete the question.

That seems to me to be a maintanance nightmare.
0
 
LVL 6

Accepted Solution

by:
Mindphaser earned 0 total points
ID: 7138143
Axter

The delete button was removed until the final rewrite. The functionality was never really inplemented the right way. For now to delete a question you have to post a request in CS. Sorry for the inconvenience.

Points refunded and moved to PAQ

** Mindphaser - Community Support Moderator **
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question