Namespace problem

T

tech

Hi, i have the following problem

In file1.h

namespace A
{
class Bar
{
void foo();

};

}


In file2.h

class Bar;

class User
{

Bar* pBar;

};


In file2.cpp

#include "file2.h"
#include "file1.h"

User::func()
{

pBar = new Bar;
pBar->foo(); // linker error here
}


If i try to forward declare in file2.h like this

class A::Bar i get a compiler error saying that A is not a class or
namespace
with MSVC++8.

How to solve this issue.
 
M

Martin T.

tech said:
Hi, i have the following problem

In file1.h

namespace A
{
class Bar
{
void foo();

};

}


In file2.h

class Bar;

class User
{

Bar* pBar;

};


In file2.cpp

#include "file2.h"
#include "file1.h"

User::func()
{

pBar = new Bar;
pBar->foo(); // linker error here
}


If i try to forward declare in file2.h like this

class A::Bar i get a compiler error saying that A is not a class or
namespace
with MSVC++8.

How to solve this issue.

I think you have to reopen the namespace:

namespace A {
class Bar;
}

class User {
A::Bar* pBar;
}

br,
Martin
 
T

tech

Hi, thanks now i have another problem though

In file1.h


namespace A
{
class Bar
{
void foo();


};
}

file1.cpp

namespace A
{
Bar::Bar()
{
}
}


In file2.h
namespace A {
class Bar;
}

class User
{


A::Bar* pBar;



};


In file2.cpp

#include "file2.h"
#include "file1.h"


User::func()
{

pBar = new A::Bar;
pBar->foo();

}


Now i have compiler error saying Bar has no default constructor
 
B

Bo Persson

Razii said:
Time in secs as N increases
N 12 14 16
g++ 0.442s 2.343s 13.743s
JVM 0.185s 0.339s 1.281s (-server -Xms64m)
JET 0.284s 0.506s 1.528s

Weird, very weird. According to their site, g++ is 1.6 times faster
than JVM but I don't get the same result using the same source that
they have on their site. With n=13, g++ is 7.5 times slower. huh?
Why? In any case, JVM is faster than JET in this benchmark anyway.


Why don't you just link to the binary-trees result page, so we can all
start using Haskell, ML, Lisp, and Basic for our high performance
programs?

http://shootout.alioth.debian.org/gp4/benchmark.php?test=binarytrees&lang=all


Must be a bad benchmark, as Java 6 -server is at 16th place!


Bo Persson
 
M

Martin Gregorie

Starting today:
binary-trees benchmark
(C++ version)
http://shootout.alioth.debian.org/gp4/benchmark.php?test=binarytrees&lang=gpp&id=2

(java version)
http://shootout.alioth.debian.org/gp4/benchmark.php?test=binarytrees&lang=java&id=2

g++ -pipe -O3 -fomit-frame-pointer -finline-functions binarytrees.cpp -o
binarytrees.exe -march=native

jc -inline+ binarytrees.class

Time in secs as N increases....
N 12 14 16
g++ 0.442s 2.343s 13.743s
JVM 0.185s 0.339s 1.281s (-server -Xms64m) JET 0.284s
0.506s 1.528s

Weird, very weird. According to their site, g++ is 1.6 times faster than
JVM but I don't get the same result using the same source that they have
on their site. With n=13, g++ is 7.5 times slower. huh? Why? In any
case, JVM is faster than JET in this benchmark anyway.
There's a hidden factor here: you're not just benchmarking languages and
compilers. You're comparing operating systems as well and doing it with an
algorithm that is hammering memory management.

In this case you're comparing Gentoo Linux against an undeclared edition
of Windows. Linux, like all Unices, is pretty slick at memory management.
It has to be because its design requires it to be fast at spawning
processes and tidying up after they die. UNIX assumes that a lot of small
short life processes are likely to be involved in doing any significant
task while Windows tends to use a single, monolithic program to do the
same job. Things may have changed in the more recent Windows releases, but
in the past its memory management has been spectacularly bad: both slow
and leak-prone.

Binary tree programs tend to allocate small pieces of memory each time a
new node is added to the tree. If, as is likely, the C++ implementation
calls the OS each time it adds a node to the tree while the JVM only asks
the OS for large memory chunks which it internally slices into tree nodes,
then I'd expect the Java process to be a lot faster than the C++ under
Windows. Gentoo memory management is likely to have a similar efficiency
to the JVM, so the website's performance difference could easily be down
to just the JIT and GC overheads.

I strongly suspect that you're seeing the difference in memory management
speeds between Linux and Windows and that this is big enough to mask any
other performance differences between Java and C++.
 
I

Isaac Gouy

Well, as I must find something new to do.http://razi2.blogspot.com/2008/04/shootout-incomplete-benchmarks-game...

The site at:http://shootout.alioth.debian.org/gp4/benchmark.php?test=all〈=all

has many computer languages performance on a same few dozen
benchmarks.

For some reason, the java compiled with Jet is not on the site. I
asked him to add Jet to the list, and he gave a really odd excuse
about "license" restrictions. There is nothing in Jet license that
restricts him from posting benchmark results (it's been done on many
web sites).

We don't have a JET license.

Excelsior JET non-commercial licensing is conditional - "Authors of
non-commercial Java software willing to exchange links and/or
otherwise promore Excelsior JET are welcome to apply for a free
license."
http://www.excelsior-usa.com/jetpricing.html#non-comm

The fact that others break Excelsior JET license conditions is not a
justification for us to break those license conditions.


Later he gave even a more weird excuse that they will have
to link to the Jet web page if they include Jet results. Huh? Why
would that be a problem? They already link to every compiler used in
the shootout. The number one ranked compiler on their list is Intel
C++ compiler which is a commercial product (http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&l...
). They link to Intel C++ compiler.

Well, since they refused to add what is commonly claimed (we will see)
to be the fastest java compiler, I will run g++ vs jet on my computer
(using the same code that they have and similar flags that they use
for g++). We can then estimate where Jet would rank on their
(incomplete) list .

What I am using:
gcc version 4.3.0 (GCC TDM-2 for MinGW)
Jet version: 6.4 betahttp://www.excelsior-usa.com/jetdlbeta.html

To record time, I downloaded Cygwin and used "time" command. The
output is directed to >/dev/null

Starting today:
binary-trees benchmark
(C++ version)http://shootout.alioth.debian.org/gp4/benchmark.php?test=binarytrees&...

(java version)http://shootout.alioth.debian.org/gp4/benchmark.php?test=binarytrees&...

g++ -pipe -O3 -fomit-frame-pointer -finline-functions binarytrees.cpp
-o binarytrees.exe -march=native

jc -inline+ binarytrees.class

Time in secs as N increases....
N 12 14 16
g++ 0.442s 2.343s 13.743s
JVM 0.185s 0.339s 1.281s (-server -Xms64m)
JET 0.284s 0.506s 1.528s

Weird, very weird. According to their site, g++ is 1.6 times faster
than JVM but I don't get the same result using the same source that
they have on their site. With n=13, g++ is 7.5 times slower. huh?
Why? In any case, JVM is faster than JET in this benchmark anyway.


Different hardware.

Cygwin not Linux

Different gcc.

Windows JVM or Linux JVM?
 
L

ldv

We don't have a JET license.

Excelsior JET non-commercial licensing is conditional

Did you ask Excelsior for a free license? If yes, did they refuse?

I know for sure they are used to provide free licenses under
conditions other than those you quoted, e.g. to beta testers, and,
guess to whom, to people conducting Java performance studies.

I also recall that, say, the IBM JDK license used to specifically
prohibit publication of benchmark results... Have you reviewed the
licenses of all products you are comparing?

LDV
 
I

Isaac Gouy

Did you ask Excelsior for a free license? If yes, did they refuse?

I haven't asked, I'm not interested in promoting Excelsior JET as a
condition of using it non-commercially.

I know for sure they are used to provide free licenses under
conditions other than those you quoted, e.g. to beta testers, and,
guess to whom, to people conducting Java performance studies.

I also recall that, say, the IBM JDK license used to specifically
prohibit publication of benchmark results... Have you reviewed the
licenses of all products you are comparing?

We certainly try to keep up with the changing license conditions. I
removed the Intel compiler measurements when it seemed that the
license forbade publication of benchmark measurements - and now it's
clear that the license for the current non-commercial versions does
not forbid publication of benchmark measurements we are showing the
Intel compilers once more.

Incidentally 4 of the Intel C++ programs don't seem to have the
correct compiler options

http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&lang=icpp&lang2=icpp

I'd welcome advice on how to fix them.
 
R

Roedy Green

For some reason, the java compiled with Jet is not on the site. I
asked him to add Jet to the list, and he gave a really odd excuse
about "license" restrictions. There is nothing in Jet license that
restricts him from posting benchmark results (it's been done on many
web sites). Later he gave even a more weird excuse that they will have
to link to the Jet web page if they include Jet results. Huh? Why
would that be a problem? They already link to every compiler used in
the shootout. The number one ranked compiler on their list is Intel
C++ compiler which is a commercial product (
http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&lang=icpp
). They link to Intel C++ compiler.

you can download the trial version of the Jet compiler which generates
code just like the production one and run the benchmarks yourself.
see http://mindprod.com/jgloss/jet.html
 
L

ldv

I haven't asked, I'm not interested in promotingExcelsiorJETas a
condition of using it non-commercially.

I seem to have failed to explain, sorry. I am sure you can get a free
Excelsior JET license without any such obligations. Just email them a
link to your site and ask if they want their product included in your
studies.

LDV
 
C

cmello

I think you missed the constructor in file1.h, and I guess you want it
public like this:

namespace A
{
class Bar
{
void foo();

public:
Bar();
};
}

[]
Mello
 
I

Isaac Gouy

There is another problem with theshootoutsite. The site forces the
java version to either use only -server or use only -Xms64m flag.


That's not true! Stop making stuff up!

The JVM flags are clearly shown on the webpages.
 
I

Isaac Gouy

It's true. The only flag I see are -server -Xbatch -classpath

why not use -server -Xms64m together? Why not use -client if that
helps in a particular benchmark? why have two and three versions, one
only for -server and other only for -client and the other only for
-Xms64m? There are many other flags that can help in cases where a lot
GC activity is included.


That's not true! Stop making stuff up!

The JVM flags are clearly shown on the webpages.

http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=binarytrees&lang=javaxx&id=2#log
 
I

Isaac Gouy

The site so confusing.


Why have you not apologized for repeatedly posting false information,
even after you had been told it was false?


Why is -Xms64m flag not added here?
http://shootout.alioth.debian.org/gp4/benchmark.php?test=binarytrees&...

Why is -Xms64m -server not shown in the ranking on the page?

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all〈=all

Why is it not shown on ranking on this page?

http://shootout.alioth.debian.org/gp4/benchmark.php?test=binarytrees&...

In any case, there should be one java result that uses the best JVM
options/flags depending on the benchmark.

Bo Persson claimed that java version is ranked 16 but with -server and
Xms64m, it's ranked number 1 in this benchmark. Obviously he too
missed this link on your site given the confused nature of the website
with tons of different flag version used for java instead of one
version with best flags (including -client) depending on the
situation.


Bo Persson followed the Java URL you posted on Apr 19, 8:24pm & 8:27pm

http://groups.google.com/group/comp.lang.c++/msg/90b91dfa158e6ac6

You didn't post the Java -Xms64m URL even though you posted the Intel C
++ URL for the website that shows Java -Xms64m

Why didn't you post the Java -Xms64m URL?


Why are you still not posting URLs that show these Java measurements?

http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&lang=all
 
B

Bo Persson

Razii said:
No, it was not false. There is no -Xms64m and -server linked from
the main page.

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=all

Anyone can go there and check it. You dug up a link but it's not on
the main page. Also,-Xms64m "version" always uses -server flag. Why?
Why it must always use -server flag if the client flag does better
in some cases?


Or perhaps Bo Person went to the main page

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=all

and found the list doesn't have -Xms64m and -server. Anyone can go
there and check it.

I actually went to the main page, and chose binary-tree in benchmark
selector at the top of the page. That brought me here:

http://shootout.alioth.debian.org/gp4/benchmark.php?test=binarytrees&lang=all

Found it very "interesting" with a benchmark where ML, Haskell,
Erlang, and Lisp is at the top, shortly followed by Eiffel and Basic.
Must have taken a lot of effort to invent that test! :)


If you look in the "penalty box" at the bottom of the page, you will
of course find that g++ has the best result, but was disqualified for
chosing a faster memory allocation scheme. ROTFL!


Bo Persson
 
I

Isaac Gouy

No, it was not false. There is no -Xms64m and -server linked from the
main page.

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all〈=all

Anyone can go there and check it. You dug up a link but it's not on
the main page. Also,-Xms64m "version" always uses -server flag. Why?
Why it must always use -server flag if the client flag does better in
some cases?


Or perhaps Bo Person went to the main page

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all〈=all

and found the list doesn't have -Xms64m and -server. Anyone can go
there and check it.


Why are you posting false information that a page titled "Create your
own Ranking" is the main page?

The main page is titled "The Computer Language Benchmarks Game".

Why are you posting false information that "There is no -Xms64m and -
server linked from the main page"? "Anyone can go there and check it"
and find the link "Java 6 -Xms64m initial java server heap size 64m"

http://shootout.alioth.debian.org/
 
I

Isaac Gouy

I actually went to the main page, and chose binary-tree in benchmark
selector at the top of the page.


There is no benchmark selector on the main page

http://shootout.alioth.debian.org/

That brought me here:

http://shootout.alioth.debian.org/gp4/benchmark.php?test=binarytrees&...

Found it very "interesting" with a benchmark where ML, Haskell,
Erlang, and Lisp is at the top, shortly followed by Eiffel and Basic.
Must have taken a lot of effort to invent that test! :)

If you look in the "penalty box" at the bottom of the page, you will
of course find that g++ has the best result, but was disqualified for
chosing a faster memory allocation scheme. ROTFL!

Bo Persson

It's always faster to run just the lap in the stadium rather than the
whole marathon.
 
I

Isaac Gouy

Now he should stop blaming me for posting wrong link and apologize.
The main page doesn't have -Xms64m -server (#1 ranked in this
benchmark). In fact, the main page ranking only uses -server flag (and
not whatever flag that would be fastest in a particular benchmark). I
was correct after all.

The main page is titled "The Computer Language Benchmarks Game".

Why are you posting false information that "There is no -Xms64m and -
server linked from the main page"? "Anyone can go there and check it"
and find the link "Java 6 -Xms64m initial java server heap size 64m"

http://shootout.alioth.debian.org/

Stop posting false information!

The guy is weird, by the way. He also has strange excuses for not
including Jet (even though many other commercial compilers are
included and links to the their commercial site posted).

Some compilers are included which have freely available non-commercial
licenses (the Jet non-commercial license is not freely available -
it's restricted).
 
I

Isaac Gouy

There is. If you click on "Show" tab, it takes you to this page.

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all〈=all

There is no -server -Xms64m on this ranking. That's how Bo apparently
found the link. You should apologize by claiming Bo followed my link.
He didn't. Also, you didn't explain why -Xms64m must always use
-server? Why not -client sometimes if that helps in some cases? Or
other flags?

Bo wrote: "I actually went to the main page, and chose binary-tree in
benchmark selector at the top of the page. That brought me here...".

http://groups.google.com/group/comp.lang.c++/msg/bd2a2ac332ddd04b

As you just discovered - Bo could not have chosen "binary-tree in
benchmark selector at the top of the page".

There is no "binary-tree in benchmark selector at the top of the
page".

There's a button hard-coded to an entirely different webpage!
 
I

Isaac Gouy

It's clear by now that you and your site has zero credibility. It's a
scam. I won't waste any more time on you after this post.

To summarize, anyone can go to the main site

http://shootout.alioth.debian.org/

where there is no ranking, no numbers, nothing. If you click on "show"
tab, that takes you to this page

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all〈=all

that does have ranking, but there is no -Xms64m. Also, why -Xms64m
must always use -server flag and vice versa? This guy failed to answer
that. Even Bo Person told him that this is how he found the 16th place
ranking, but this idiot, instead of admitting the obvious, keeps
spining and twisting.

I am done with this fool and will continue posting the rest of the
results


To summarize, anyone can go to the main site

http://shootout.alioth.debian.org/

where there's a "Programming language measurements A to Z" link list
which includes

Java 6 -Xms64m initial java server heap size 64m
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top