473,487 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

"Partially elided initialisation" on initialising 2-D array

Running lint on code initialising a local 2-D array gives a warning.

void f(void)
{
int a[5][3] = { 0 };
...

lint gives "warning: Partially elided initialisation..."

Should this be happening, and what does it mean (the warning does not
occur for 1-D array)?

[Running "lint -std1 -u -x a.c" on Tru64 platform]

TIA
Mark

Dec 20 '06 #1
3 1692
ma**********@thales-is.com wrote:
Running lint on code initialising a local 2-D array gives a warning.

void f(void)
{
int a[5][3] = { 0 };
...

lint gives "warning: Partially elided initialisation..."

Should this be happening, and what does it mean (the warning does not
occur for 1-D array)?
Try using one set of braces for each dimension:

int a[5][3] = { {0} };

That will probably shut lint up. The effect of the code should be the
same either way, since non-initialised members of a partly-initialised
compound object should be initialised as if explicitly given a 0 value.
IOW, the warning is not entirely bogus (what it says is true), but not
very meaningful (what it says is not a problem).

Richard
Dec 20 '06 #2
ma**********@thales-is.com writes:
Running lint on code initialising a local 2-D array gives a warning.

void f(void)
{
int a[5][3] = { 0 };
...

lint gives "warning: Partially elided initialisation..."

Should this be happening, and what does it mean (the warning does not
occur for 1-D array)?

[Running "lint -std1 -u -x a.c" on Tru64 platform]
"{ 0 }" is a perfectly good way to specify initializing something to
all zeros. (Note: it specifies logical zero values for each
component, not necessarily all-bits-zero; pointers will be set to
null, and floating-point numbers to 0.0.)

On the other hand, a C implementation is free to issue any diagnostics
it likes, for any reason:

warning: No errors detected on this line
warning: Danger, Will Robinson!

And lint isn't even a C implementation.

You might complain to the authors of your particular lint about the
warning for this correct and idiomatic construct, but there's no
conformance issue.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 20 '06 #3
On Wed, 20 Dec 2006 15:09:40 -0800, Keith Thompson <ks***@mib.org>
wrote:
>ma**********@thales-is.com writes:
>Running lint on code initialising a local 2-D array gives a warning.

void f(void)
{
int a[5][3] = { 0 };
...

lint gives "warning: Partially elided initialisation..."

Should this be happening, and what does it mean (the warning does not
occur for 1-D array)?

[Running "lint -std1 -u -x a.c" on Tru64 platform]

"{ 0 }" is a perfectly good way to specify initializing something to
all zeros. (Note: it specifies logical zero values for each
component, not necessarily all-bits-zero; pointers will be set to
null, and floating-point numbers to 0.0.)

On the other hand, a C implementation is free to issue any diagnostics
it likes, for any reason:

warning: No errors detected on this line
warning: Danger, Will Robinson!

And lint isn't even a C implementation.

You might complain to the authors of your particular lint about the
warning for this correct and idiomatic construct, but there's no
conformance issue.
On HP-UX, we get a warning saying that partially elided
initializations may be handled differently when compiled in ANSI mode.
I suppose that means that their pre-ANSI compiler did something
non-standard.

--
Al Balmer
Sun City, AZ
Dec 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5199
by: john bailo | last post by:
I wrote a c# program that does some file manipulation on a remote server. Testing it from my workstation, it ran fine. When I copied it to another server, and ran it from there, on load, it...
134
7743
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
3
2341
by: Dmitri Shvetsov | last post by:
Hi, Maybe somebody knows why it's happening? I wrote a C# Windows Application working with the remote database through a DataSet. It works cool from my computer but when I gave this...
4
2036
by: Dany P. Wu | last post by:
Hi everyone, I'm not entirely sure if this is the best way of going about it, but here's the scenario.......... I have two datagrid, each bound to a datatable which have checkbox columns....
0
1433
by: SGibson | last post by:
How would I display a partially checked node? What I mean by this is, rather than a completely checked or unchecked node, a node that displays a grey check mark when some of its children are...
4
12588
by: lawrence k | last post by:
I've a file that starts like this: <form id="pdsForm" method="post" action="/mcControlPanel.php" class="mcForm" charset="UTF-8" enctype="multipart/form-data" > and it contains this input: ...
2
2070
by: Christoph Conrad | last post by:
Hi, given the following test case, with CString from Microsofts MFC: ================================================== file 1: CString arr; ...
49
2838
by: aarklon | last post by:
Hi all, See:- http://www.cs.princeton.edu/introcs/faq/c2java.html for C vs Java in number crunching http://husnusensoy.blogspot.com/2006/06/c-vs-java-in-number-crunching.html
10
7438
by: Horacius ReX | last post by:
Hi, in some C program I need to port to some architecture, I send to a function the parameter char with predefined values. Inside the function, this data is read and something is calculated. But...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
267
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.