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.
"Vicky" <Vi***@discussions.microsoft.com> wrote in message
news:87**********************************@microsof t.com...
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
"Bruno van Dooren" wrote:
The release executable for this empty console application is 3 K.
i set the optimization to /O1 (minimal size) and set /Os to favor size.
I also set the runtime library to /MD to use the multithreaded dll. that
way
the runtime is linked dynamically instead of statically. this brought the
size from 21 k to 3 k.
for your tests, did you use the same project on different machines, or
not?
the same confugration should have the same results on different machines.
kind regards,
Bruno.
"Vicky" <Vi***@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com... > 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