473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

odd problem with static initializers


I have the following code which won't compile:

typedef myType1 {
unsigned short v1,
unsigned char v2,
unsigned char v3
}

enum signals {
SIG_A,
SIG_B,
SIG_C
};

static const myType myEvents[] = {
{SIG_A, 0, 0},
{SIG_B, 0, 0},
{SIG_C, 0, 0}
};

The compiler error is
error: a brace-enclosed initializer is not allowed here before '{' token

This compiled fine with an old version of gcc, I think 2.96. This error
came from a more recent
vintage, 3.3.1.

Can anyone tell me why this isn't compiling? Thanks.

Ric
Jul 22 '05 #1
3 1554
Ric Has wrote:


I have the following code which won't compile:

typedef myType1 {
unsigned short v1,
unsigned char v2,
unsigned char v3
}
What's this? Perhaps you meant

struct myType1 {
unsigned short v1;
unsigned char v2;
unsigned char v3;
};
or even this unusual:
typedef struct myType1 {
unsigned short v1;
unsigned char v2;
unsigned char v3;
};



enum signals {
SIG_A,
SIG_B,
SIG_C
};

static const myType myEvents[] = {

static const myType1 myEvents[] = {
{SIG_A, 0, 0},
{SIG_B, 0, 0},
{SIG_C, 0, 0}
};


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #2
Correction:
Ioannis Vranos wrote:
or even this unusual:

typedef struct {
unsigned short v1;
unsigned char v2;
unsigned char v3;
}myType1;

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #3
Yes, I meant struct, not typedef. I have the same error when I do typedef
struct myType1...

On Wed, 13 Oct 2004 04:09:53 +0300, Ioannis Vranos
<iv*@guesswh.at.grad.com> wrote:
Ric Has wrote:
I have the following code which won't compile:
typedef myType1 {
unsigned short v1,
unsigned char v2,
unsigned char v3
}


What's this? Perhaps you meant

struct myType1 {
unsigned short v1;
unsigned char v2;
unsigned char v3;
};
or even this unusual:
typedef struct myType1 {
unsigned short v1;
unsigned char v2;
unsigned char v3;
};


enum signals {
SIG_A,
SIG_B,
SIG_C
};
static const myType myEvents[] = {

static const myType1 myEvents[] = {
{SIG_A, 0, 0},
{SIG_B, 0, 0},
{SIG_C, 0, 0}
};



--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 22 '05 #4

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

Similar topics

7
by: Paul Sheer | last post by:
I need to automatically search and replace all fixed size buffer strcpy's with strncpy's (or better yet, strlcpy's) as a security and stability audit. The code base is large and it is not feasable...
6
by: Jamal | last post by:
I am working on binary files of struct ACTIONS I have a recursive qsort/mergesort hybrid that 1) i'm not a 100% sure works correctly 2) would like to convert to iteration Any comments or...
90
by: Jhon smith | last post by:
Hi all,Just wondering are there any problems with learning c from older books,as I have picked up some from 1988,1994,1997,1998. By using books of this age(Im on a tight budget)am I going to...
4
by: fred | last post by:
Hi, can someone please explain to me how a static member of a class works. For example if I have: public Class1 public static Class2 myClass2 = new Class2; public static Int16 thisValue = 200;...
9
by: A J Le Couteur Bisson | last post by:
Could someone please confirm that static class constructors are only called at the first use of a non-static constructor on the class, or am I doing something wrong? If this is indeed the case...
3
by: Dave | last post by:
Hi everyone, Is it possible, using an Attribute or by some other means, to notify the C# Compiler to serialize all static field's that have initializers before code in an explicit static...
10
by: Ni | last post by:
I found out smth strange in g++ >= 3.3.5 => I was able to do register char buff;//// where outSTDBuffer is a variable!!!! Is it a bug in gcc or specification of c++ changed?? I've noticed this...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
5
by: Jesper Schmidt | last post by:
Hi, I have a relatively large C++ code base, which requires that static initializers are called when a dll is loaded. This seems to work well for native code, but it does not work for files...
1
by: Visame | last post by:
The following example is from C++ Standard(ISO14882) 9.4.2 Static data members class process { static process* run_chain; static process* running; }; process* process::running =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...
0
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
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,...

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.