Solved

null statement at the end of  namespace scope

Posted on 2002-04-30
17
267 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

862 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now