I apologise perhaps for a simple question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

my friends and i have been confused by this problem.
On a veriety of systems we have tested compiling a simple hello word
applicaation to check optimisation of C++ in 2003 VS.NET.
However on one of the machines, the best we can get is 61k under a blank
win32 console app.

We were trying to wrk out what we should tweak as we have tried excluding
Libraries, and a few other tweaks as suggested in forums.

Your help is much appreciated

Thankyou

Vicky
 
Simply ensure that your code is not calling anything in the VC runtime
library. Unfortunately, I don't think this is possible from a console
application. Regardless, you can confirm this by not linking to any of the
standard libraries (see /NODEFAULTLIBRARY). Stick to Win32 API calls only.

See the notes section in
http://msdn2.microsoft.com/en-us/library/h02f9ttw.aspx

Brian
 
Bruno,

I followed your optimisation settings exactly, and I have a file of 4k
Thankyou ever so much, I am only recently getting to grips with C++ and VS
..NET and as such I was somewhat confused as to the lack of optimsation :o)

Would it do much harm to set these 3 options as a default global template
for each project or is it best to assign them on a per-project basis?

regards

vicky
 
Vicky said:
Hi,

my friends and i have been confused by this problem.
On a veriety of systems we have tested compiling a simple hello word
applicaation to check optimisation of C++ in 2003 VS.NET.
However on one of the machines, the best we can get is 61k under a blank
win32 console app.

We were trying to wrk out what we should tweak as we have tried excluding
Libraries, and a few other tweaks as suggested in forums.

Are you sure you weren't looking at a Debug build in the 61K case? How are
you building the project - from a Visual Studio project (.vcproj file) or
something else?

-cd
 
It won't do you any harm to set these changes as part of a template, but you
should only do this for release builds. otherwise you might have the side
effect that some code gets optimized away. in that case, stepping through
the code could skip lines or things like that.

when using optimization, you also have to be careful when working with data
that is used globally. the compiler might decide that some piece of code is
doing nothing that has a visible effect,and throw it away, even though you
really use it. you have to use the 'volatile' keyword so that the compiler
knows that global data values really do change. this can be an important
factor if you share global data between threads or processes, or when
developing device drivers.

not using the volatile keyword could make the compiler decide to not really
read a pointer value, but use the value that it has in the cpu registers for
that memory address. it can do this because it could assume that the value
doesn't change where the compiler can see it.

sorry for the long winded explanation. but not using volatile correctly can
lead to problems at high optimization levels, though i have to say VC2003
and vs2005 have been much better than vc6.

kind regards,
Bruno.
 
Back
Top