Re: How do I delete a folder through code?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



One of the advantages of this technique is that you don't need to know what name the
programmer assigned to the first member. In a rational world, there would be one,
corporate-wide, standard for this name, but instead, every programmer got to choose his or
her own name (this is why I often wonder about the lack of any adult supervision of the
programmers). But I don't need to remember what the name is if I use that form of
initialization!
joe

On Fri, 09 May 2008 12:09:27 -0500, "Doug Harrison [MVP]" <dsh@xxxxxxxx> wrote:

On Thu, 8 May 2008 21:31:08 -0700, "Alexander Grigoriev"
<alegr@xxxxxxxxxxxxx> wrote:

Actually, {0} initialization is done by the compiler by emitting memset
equivalent, which is pretty much the same as ZeroMemory produces.

The last time I looked at this, which was a looooooong time ago,
initialized static duration data was stored in the DATA segment, where it
added to the executable size, while uninitialized static data was stored in
the BSS segment, where it took up no space in the executable. Given that
the language specifies that uninitialized static data is set to zero
anyway, SOP is to never explicitly initialize static duration data to zero.

Data stored in the BSS is initialized to zero by a memset equivalent, and
this is also done for local non-static variables, i.e. auto variables, as
you said. I'm unaware I ever used a compiler that would create an image of
the initialization data and copy it to these objects. Thus, there is no
reason not to use {0} on the variables for which it is appropriate, namely,
autos. In Windows programming, it's even more common to see things like:

T x = { sizeof(T) }; // x is auto

This is an idiomatic way to initialize a data structure whose first member
specifies the size, while concomitantly zero-initializing the rest of the
struct, which is done with memset equivalent.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Contructing a dir. tree
    ... Perl programmer to think that variables must be initialized, ... The reason I set it to zero is for the same reason I set ... Again, while *you* may know the initialization is not needed, a novice ... he could be printing the Gutenberg Bible for every directory level. ...
    (comp.lang.perl.misc)
  • Re: automatic variables are not initialized correctly?
    ... Fortran ALLOCATABLE in COMMON. ... F77 did not have initialization statements, so it was less confusing there. ... out of context, then it is not clear whether that initialization is done once with an implied SAVE, or whether it is done repeatedly every time the subprogram in invoked. ... fortran, then you might be able to deduce what is most likely, but I think that is asking too much of a programmer, especially a modern programmer who must use several languages and where different languages treat this situation differently. ...
    (comp.lang.fortran)
  • Re: Structure initialization
    ... that might be unclear to the student programmer who is going to ... the code to explicitly initialize all the values "just in case" someone ... the explicit initialization would just ...
    (comp.lang.c)
  • Re: Beginner level VB.NET question
    ... were a C# programmer. ... object to nothing somewhere in the code, but not realizing it is the same ... NullReferenceException;(Am I checking whether my reference Object is ... ' Initialization and other good stuff ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Beginner level VB.NET question
    ... were a C# programmer. ... object to nothing somewhere in the code, but not realizing it is the same ... NullReferenceException;(Am I checking whether my reference Object is ... ' Initialization and other good stuff ...
    (microsoft.public.dotnet.languages.vb)