user15425: I'm compiling my code in Arduino IDE. I have an array that I want to 0-initialize. I know memset works on Arduino, but I'm used to this way from my desktop C++ programming practice:
int array[100] = {0};

I couldn't find any info on whether or not this construct works on Arduino. I think it should since it uses GCC compiler. Even though it may be modified, I still expect it to remain C and C++-compliant. Still, can you confirm for me that this standard-compliant C/C++ construct works on Arduino?

user313: The GNU cross compilers for Arduino use C/C++ front-ends and meet the language specs. You can expect fully compliant output. "Arduino language" is a misnomer. The Arduino IDE will try to assist new programmers by, for example, automagically discovering library references and inserting the required #includes for you, but the resulting code is C++ and presented to a C++ compiler. The IDE provides a main() function that calls setup() and loop() (and serialEventRun() if you provide one) thereby reminding the programmer to initialize whatever needs to be initialized before expecting things to work right. However you can write proper C++ and get what you've come to expect. You'd have to go 'behind the IDE's back' as it were to suppress the auto-supplied main() function, but the toolchain doesn't care how that part was done, as long as there is one.
I tested this this trivial program:
int array[100];
void setup() {
  // put your setup code here, to run once:
   for(uint8_t i = 0; i < sizeof(array); ++i)
      array[i] = i;
}

void loop() {
  // put your main code here, to run repeatedly:

}

with both the Arduino IDE and Sloeber - Eclipse with the EclipseArduino plugin, which routinely provides a basic memory map after compilation - and with and without the initialization expression = {0}. I found no difference in the size of the output in either environment, with or without the initialization. In all four cases, the .bss was 209 bytes, 200 bytes larger than without the global array.

user55899: This construct does work in Arduino IDE. In fact, = { 0 } is one of the iconic idioms of C language. It can be used to zero-initialize an object of any type in C. In C++ things are a bit more complicated. It will work for an int [100] array, but in general case you might be better off with = {} initializer to achieve the same effect where applicable.
It is not clear why the accepted answer claims that this construct "has no actual effect" though. This is, of course, incorrect. More precisely, this initializer is redundant ("has no effect") on variables with static storage duration, since such variables are default-initialized anyway (zero-initialized for int [100]), even if you don't request it explicitly. But for a local variable declaration the effect of = { 0 } is undeniable and obvious: it will zero-initialize the array (which wouldn't've been initialized without it). 
Note that even though the 0 in the = { 0 } initializes the first element of the array, this initializer ultimately triggers zero-initialization if the entire array.

user4143: 
I'm used to this way from my desktop C++ programming practice:
int array[100] = {0};

I couldn't find any info on whether or not this construct works on Arduino.

The = {0} has no actual effect. It is the same as:
int array[100];

Uninitialized static / global variables, and variables explicitly initialized to 0, are placed in the .bss section of memory.
This section is initialized to 0 by the CRT (C Runtime) code (the startup code for the system).
The compiler is responsible for placing these variables in the .bss, but it is the job of the startup (CRT) code to initialize it to zero.
This is standard C operation and is not likely to ever change since it would break all sorts of things.
Note: this does NOT apply to local variables allocated on the stack. These must be initialized to 0 if you want them to start as 0.

15425: <p>I'm compiling my code in Arduino IDE. I have an array that I want to 0-initialize. I know <code>memset</code> works on Arduino, but I'm used to this way from my desktop C++ programming practice:</p>

<pre><code>int array[100] = {0};
</code></pre>

<p>I couldn't find any info on whether or not this construct works on Arduino. I think it should since it uses GCC compiler. Even though it may be modified, I still expect it to remain C and C++-compliant. Still, can you confirm for me that this standard-compliant C/C++ construct works on Arduino?</p>
 313: <p>The GNU cross compilers for Arduino use C/C++ front-ends and meet the language specs. You can expect fully compliant output. "Arduino language" is a misnomer. The Arduino IDE will try to assist new programmers by, for example, automagically discovering library references and inserting the required #includes for you, but the resulting code is C++ and presented to a C++ compiler. The IDE provides a <code>main()</code> function that calls <code>setup()</code> and <code>loop()</code> (and <code>serialEventRun()</code> if you provide one) thereby reminding the programmer to initialize whatever needs to be initialized before expecting things to work right. However you can write proper C++ and get what you've come to expect. You'd have to go 'behind the IDE's back' as it were to suppress the auto-supplied <code>main()</code> function, but the toolchain doesn't care how that part was done, as long as there is one.</p>

<p>I tested this this trivial program:</p>

<p>int array[100];</p>

<pre><code>void setup() {
  // put your setup code here, to run once:
   for(uint8_t i = 0; i &lt; sizeof(array); ++i)
      array[i] = i;
}

void loop() {
  // put your main code here, to run repeatedly:

}
</code></pre>

<p>with both the Arduino IDE and Sloeber - Eclipse with the EclipseArduino plugin, which routinely provides a basic memory map after compilation - and with and without the initialization expression <code>= {0}</code>. I found no difference in the size of the output in either environment, with or without the initialization. In all four cases, the .bss was 209 bytes, 200 bytes larger than without the global array.</p>
 55899: <p>This construct does work in Arduino IDE. In fact, <code>= { 0 }</code> is one of the iconic idioms of C language. It can be used to zero-initialize an object of <em>any</em> type in C. In C++ things are a bit more complicated. It will work for an <code>int [100]</code> array, but in general case you might be better off with <code>= {}</code> initializer to achieve the same effect where applicable.</p>

<p>It is not clear why the accepted answer claims that this construct "has no actual effect" though. This is, of course, incorrect. More precisely, this initializer is <em>redundant</em> ("has no effect") on variables with static storage duration, since such variables are default-initialized anyway (zero-initialized for <code>int [100]</code>), even if you don't request it explicitly. But for a <em>local</em> variable declaration the effect of <code>= { 0 }</code> is undeniable and obvious: it will zero-initialize the array (which wouldn't've been initialized without it). </p>

<p>Note that even though the <code>0</code> in the <code>= { 0 }</code> initializes the first element of the array, this initializer ultimately triggers zero-initialization if the <em>entire</em> array.</p>
 4143: <blockquote>
  <p>I'm used to this way from my desktop C++ programming practice:</p>

<pre><code>int array[100] = {0};
</code></pre>
  
  <p>I couldn't find any info on whether or not this construct works on Arduino.</p>
</blockquote>

<p>The <code>= {0}</code> has no actual effect. It is the same as:</p>

<pre><code>int array[100];
</code></pre>

<p>Uninitialized static / global variables, and variables explicitly initialized to 0, are placed in the <a href="https://en.wikipedia.org/wiki/.bss" rel="nofollow noreferrer">.bss</a> section of memory.</p>

<p>This section is initialized to 0 by the CRT (C Runtime) code (the startup code for the system).</p>

<p>The compiler is responsible for placing these variables in the .bss, but it is the job of the startup (CRT) code to initialize it to zero.</p>

<p>This is standard C operation and is not likely to ever change since it would break all sorts of things.</p>

<p>Note: this does NOT apply to local variables allocated on the stack. These <em>must</em> be initialized to 0 if you want them to start as 0.</p>
