UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 67770

2016.2 SDK - GCC - Incorrect Wmissing-braces error relating to the universal zero initializer {0} on ZCU102 boards

Description

There is an incorrect warning related to the universal zero initializer {0} when using a ZCU102 board with the 2016.2 release of SDK.

In C, {0} is the universal zero initializer equivalent to C++'s {} (the latter being invalid in C). 

It is necessary to use whenever you want a zero-initialized object of a complete but conceptually-opaque or implementation-defined type.

To see this warning, enable the following:

extra_compiler_flags = -Wmissing-braces -Wmissing-field-initializers

For example:

#include <stdio.h>

struct Foo {

 int arr[2];

 int num;

 char s[10];

}

int main(){

 static struct Foo myFoo = {0};

 return 0;

}

When I compile this code, I receive the following warning:

warning: (near initialization for 'myFoo.arr') [-Wmissing-braces]

Many developers would requalify -Wmissing-braces and -Wmissing-field-initializers as errors.

Solution

To work around this issue, update the C code after generation to have {{0}} instead of {0} on that line.


#include <stdio.h>
struct Foo {
 int arr[2];
 int num;
 char s[10];
}
int main(){
 static struct Foo myFoo = {{0}};
 return 0;
}
AR# 67770
Date Created 08/25/2016
Last Updated 09/12/2016
Status Active
Type General Article
Devices
  • Zynq UltraScale+ MPSoC
Tools
  • Vivado Design Suite - 2016.2