473,466 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

warning variable 'will be initialized later'

Hi All,
I have a union which is a public data member of a class. This union has
one anonymous structure. The structure is like :
union abc
{
unsigned char byte;
struct
{
unsigned char rec_ : 5;
unsigned char type_ : 2;
unsigned char dir_ : 1;
};
};

I am getting compiler warning 'will be initialized later' for struct
member that is for rec_, type_ and dir_. I am using gcc3.3 for
compilation.
How to remove this warning?
TIA,
Priti

Mar 2 '06 #1
4 2051
pr*********@gmail.com wrote:
Hi All,
I have a union which is a public data member of a class. This union has
one anonymous structure. The structure is like :
union abc
{
unsigned char byte;
struct
{
unsigned char rec_ : 5;
unsigned char type_ : 2;
unsigned char dir_ : 1;
};
};

I am getting compiler warning 'will be initialized later' for struct
member that is for rec_, type_ and dir_. I am using gcc3.3 for
compilation.
How to remove this warning?
TIA,
Priti


It's probably because your structure member has no name, which is
non-standard. Try changing it to something like:

union abc
{
unsigned char byte;
struct
{
unsigned char rec_ : 5;
unsigned char type_ : 2;
unsigned char dir_ : 1;
} s;
};
Cheers! --M

Mar 2 '06 #2
mlimber wrote:

It's probably because your structure member has no name, which is
non-standard.


Bit-fields are not required to have names. If you don't name it you
can't do anything with it, so it only provides padding.

--

Pete Becker
Roundhouse Consulting, Ltd.
Mar 2 '06 #3
Pete Becker wrote:
mlimber wrote:

It's probably because your structure member has no name, which is
non-standard.


Bit-fields are not required to have names. If you don't name it you
can't do anything with it, so it only provides padding.


I'm not sure if you're disagreeing with me or not, but in any case,
Comeau online and EDG (via Dinkumware) both reject the OP's union as
non-standard.

Cheers! --M

Mar 2 '06 #4
mlimber wrote:
Pete Becker wrote:
mlimber wrote:
It's probably because your structure member has no name, which is
non-standard.


Bit-fields are not required to have names. If you don't name it you
can't do anything with it, so it only provides padding.

I'm not sure if you're disagreeing with me or not, but in any case,
Comeau online and EDG (via Dinkumware) both reject the OP's union as
non-standard.


I see: "structure member" is ambiguous. I took it to mean "the member of
the struct", which is what he's trying to access. You meant "the struct
that's a member of the union," which is, indeed, invalid.

--

Pete Becker
Roundhouse Consulting, Ltd.
Mar 2 '06 #5

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

Similar topics

35
by: jerrygarciuh | last post by:
Hi all, I was just wondering what popular opinion is on PHP giving this warning: Warning: Invalid argument supplied for foreach() in /home/boogerpic/public_html/my.php on line 6 when...
3
by: Marcin Vorbrodt | last post by:
So I have a class Math that looks like this: Math { public: static Real PI(void); }; Real Math::PI(void) { return 4.0 * atan(1.0); }
12
by: Thomas Heinz | last post by:
Hi Consider the following program. class T { int b, a; T(int a, int b) : a(a), b(b) {} };
27
by: MK | last post by:
I am a newbie. Please help. The following warning is issued by gcc-3.2.2 compiler (pc Linux): ================================================================== read_raw_data.c:51: warning:...
40
by: Dave Hansen | last post by:
Please note crosspost. Often when writing code requiring function pointers, it is necessary to write functions that ignore their formal parameters. For example, a state machine function might...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
37
by: Joergen Bech | last post by:
(Slightly religious question): Suppose I have the following class: ---snip--- Public Class MyClass Private _MyVariable As Integer Public Property MyVariable() As Integer Get
4
by: silversurfer2025 | last post by:
Hello everyone, I am using a struct inside another class, which can be used through an empty constructor or another one. The definition looks like this: struct Entry{ int index; //line 38...
4
by: cody | last post by:
It is possible to declare and use/instantiate a class with a uninitialized readonly field without even a compiler warning. Why don't I get warnings? public class Stuff { public readonly int a;...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.