By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

Some questions about optimization,help me.

P: n/a
wqe
Hi,everyone:

the questionly code:
#include <iostream>

using namespace std;
class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f()
{
printf("%x\n",&x);
printf("%x\n",&test::func );
printf("%x\n",&test::func1 );
};
};

int main()
{
test a;
a.f();
test * ap = &a;
void(test::*pmem)(void)=&test::f;
printf("%x\n",pmem );
test b;
b.f();
test * bp = &b;
return 0;
}


if delete this 3 statements: test * ap = &a;
void(test::*pmem)
(void)=&test::f;
printf("%x\n",pmem );
test b;
in vs2003-release,in export map file and disassemble output file,
cannot
find the location of "f()".

There is an answer, the f() was defined in the class test.

but if I define test::f() out of the class test, like this:

class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f();
};

void test::f()
{
printf("%x\n",&x);
};

I also cannot find the location of "f()" in the output disassemble
file,why?

if I close the optimiztion(/0d)setting of this win32 console
program(vs2003 release), I
can find f() in the disassemble output file.
but if I open /0d,even add some parameters,returned something, and
defined
a local variable,I also cannot find f() in the disassemble output
file.

why?

Mar 12 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
wqe wrote:
Hi,everyone:

the questionly code:
#include <iostream>

using namespace std;
class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f()
{
printf("%x\n",&x);
printf("%x\n",&test::func );
printf("%x\n",&test::func1 );
};
};

int main()
{
test a;
a.f();
test * ap = &a;
void(test::*pmem)(void)=&test::f;
printf("%x\n",pmem );
test b;
b.f();
test * bp = &b;
return 0;
}


if delete this 3 statements: test * ap = &a;
void(test::*pmem)
(void)=&test::f;
printf("%x\n",pmem );
test b;
in vs2003-release,in export map file and disassemble output file,
cannot
find the location of "f()".

There is an answer, the f() was defined in the class test.

but if I define test::f() out of the class test, like this:

class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f();
};

void test::f()
{
printf("%x\n",&x);
};

I also cannot find the location of "f()" in the output disassemble
file,why?

if I close the optimiztion(/0d)setting of this win32 console
program(vs2003 release), I
can find f() in the disassemble output file.
but if I open /0d,even add some parameters,returned something, and
defined
a local variable,I also cannot find f() in the disassemble output
file.

why?
If you want to know how the Visual Studio 2003 compiler works then you
should ask on a Microsoft group. Try one of the groups in
microsoft.public.vc.*

This group is for C++ language questions only.

john
Mar 12 '07 #2

P: n/a
wqe
ok,John

telnet2008

On 3月12日, 下午2时54分, John Harrison <john_androni...@hotmail.comwrote:
wqe wrote:
Hi,everyone:
the questionly code:
#include <iostream>
using namespace std;
class test
{
int x;
void func()
{
};
void func1()
{
};
public:
void f()
{
printf("%x\n",&x);
printf("%x\n",&test::func );
printf("%x\n",&test::func1 );
};
};
int main()
{
test a;
a.f();
test * ap = &a;
void(test::*pmem)(void)=&test::f;
printf("%x\n",pmem );
test b;
b.f();
test * bp = &b;
return 0;
}
if delete this 3 statements: test * ap = &a;
void(test::*pmem)
(void)=&test::f;
printf("%x\n",pmem );
test b;
in vs2003-release,in export map file and disassemble output file,
cannot
find the location of "f()".
There is an answer, the f() was defined in the class test.
but if I define test::f() out of the class test, like this:
class test
{
int x;
void func()
{
};
void func1()
{
};
public:
void f();
};
void test::f()
{
printf("%x\n",&x);
};
I also cannot find the location of "f()" in the output disassemble
file,why?
if I close the optimiztion(/0d)setting of this win32 console
program(vs2003 release), I
can find f() in the disassemble output file.
but if I open /0d,even add some parameters,returned something, and
defined
a local variable,I also cannot find f() in the disassemble output
file.
why?

If you want to know how the Visual Studio 2003 compiler works then you
should ask on a Microsoft group. Try one of the groups in
microsoft.public.vc.*

This group is for C++ language questions only.

john- 隐藏被引用文字 -

- 显示引用的文字 -

Mar 12 '07 #3

P: n/a
John Harrison wrote:
wqe wrote:
>>why?

If you want to know how the Visual Studio 2003 compiler works then you
should ask on a Microsoft group. Try one of the groups in
microsoft.public.vc.*

This group is for C++ language questions only.
Do you have to quote the entire post in order to redirect it?

--
Ian Collins.
Mar 12 '07 #4

P: n/a
wqe wrote:
Hi,everyone:

the questionly code:
#include <iostream>

using namespace std;
class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f()
{
printf("%x\n",&x);
printf("%x\n",&test::func );
printf("%x\n",&test::func1 );
};
};

int main()
{
test a;
a.f();
test * ap = &a;
void(test::*pmem)(void)=&test::f;
printf("%x\n",pmem );
test b;
b.f();
test * bp = &b;
return 0;
}


if delete this 3 statements: test * ap = &a;
void(test::*pmem)
(void)=&test::f;
printf("%x\n",pmem );
test b;
in vs2003-release,in export map file and disassemble output file,
cannot
find the location of "f()".

There is an answer, the f() was defined in the class test.

but if I define test::f() out of the class test, like this:

class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f();
};

void test::f()
{
printf("%x\n",&x);
};

I also cannot find the location of "f()" in the output disassemble
file,why?

if I close the optimiztion(/0d)setting of this win32 console
program(vs2003 release), I
can find f() in the disassemble output file.
but if I open /0d,even add some parameters,returned something, and
defined
a local variable,I also cannot find f() in the disassemble output
file.

why?
Hello there, your question is irrelevant in this group. But in essence,
your compiler is free to optimize away test::f under certain conditions
and inline the function directly at the call site. As long your final
executable works as expected, you shouldn't worry about these details.
Mar 12 '07 #5

P: n/a
please tell me how to reply the topic

Mar 13 '07 #6

P: n/a
wufeng wrote:
please tell me how to reply the topic
But you did! If you want to quote, you need to learn to use
your news-reading software. And since it's one of those basic
tasks (and depends on the software you're using), please
consult with the 'alt.newbies' or the 'alt.usenet.newbies' or
the 'alt.usenet.software' forums. Good luck!
Mar 13 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.