473,382 Members | 1,651 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,382 software developers and data experts.

whats wrong with this ? (compilation errors)

typedef struct llist_entry_s llist_entry; /* opaque type */

struct llist_entry_s
{
llist_entry * next;
char * keyword;
char * value;

llist_entry() :next(0), keyword(0), value(0)
{
}
};
Apr 7 '07 #1
8 1583
2b|!2b==? a écrit :
typedef struct llist_entry_s llist_entry; /* opaque type */

struct llist_entry_s
{
llist_entry * next;
char * keyword;
char * value;

llist_entry() :next(0), keyword(0), value(0)
{
}
};
llist_entry() is not a valid member function declaration. Did you mean
llist_entry_s() ?

J.
Apr 7 '07 #2
On Apr 7, 9:40 pm, "2b|!2b==?" <r...@your.box.comwrote:
typedef struct llist_entry_s llist_entry; /* opaque type */
Why the typedef? I'd just write:

class llist_entry ;

(My coding standards say to only use the keyword "class" for
forward declarations.)
struct llist_entry_s
{
llist_entry * next;
char * keyword;
char * value;
llist_entry() :next(0), keyword(0), value(0)
There are two errors here: first, you didn't specify a return
type for the function, and second, you try to use an initializer
sequence which is only legal in constructors.
{
}
};
--
James Kanze (Gabi Software) email: ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Apr 7 '07 #3
"2b|!2b==?" <ro**@your.box.comwrote in message
news:Lb******************************@bt.com...
typedef struct llist_entry_s llist_entry; /* opaque type */

struct llist_entry_s
{
llist_entry * next;
char * keyword;
char * value;

llist_entry() :next(0), keyword(0), value(0)
{
}
};
You don't say what compiler errors you get.

The above code compiles successfully for me with VC++.

BTW you don't need that typedef. You could write it
like this:

struct llist_entry
{
llist_entry * next;
char * keyword;
char * value;

llist_entry() :next(0), keyword(0), value(0)
{
}
};

-Mike
Apr 7 '07 #4

"James Kanze" <ja*********@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
On Apr 7, 9:40 pm, "2b|!2b==?" <r...@your.box.comwrote:
typedef struct llist_entry_s llist_entry; /* opaque type */
Why the typedef? I'd just write:

class llist_entry ;

(My coding standards say to only use the keyword "class" for
forward declarations.)
struct llist_entry_s
{
llist_entry * next;
char * keyword;
char * value;

llist_entry() :next(0), keyword(0), value(0)
There are two errors here: first, you didn't specify a return
type for the function,
It's a constructor; no return type.
and second, you try to use an initializer
sequence which is only legal in constructors.
It is a ctor.

-Mike
{
}
};


Apr 7 '07 #5


Mike Wahler wrote:
"2b|!2b==?" <ro**@your.box.comwrote in message
news:Lb******************************@bt.com...
>>typedef struct llist_entry_s llist_entry; /* opaque type */

struct llist_entry_s
{
llist_entry * next;
char * keyword;
char * value;

llist_entry() :next(0), keyword(0), value(0)
{
}
};


You don't say what compiler errors you get.

The above code compiles successfully for me with VC++.

BTW you don't need that typedef. You could write it
like this:

struct llist_entry
{
llist_entry * next;
char * keyword;
char * value;

llist_entry() :next(0), keyword(0), value(0)
{
}
};

-Mike
Ah, I'm back now - I needed the break (and some coffee). I sorted this
one out. It was due to the file extension (*.c) - it was expecting C
code - so compiler barfed when it got to the initialization list ...
>
Apr 8 '07 #6
"Mike Wahler" <mk******@mkwahler.netschrieb im Newsbeitrag
news:fI********************@newsread2.news.pas.ear thlink.net...
>
"James Kanze" <ja*********@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
On Apr 7, 9:40 pm, "2b|!2b==?" <r...@your.box.comwrote:
typedef struct llist_entry_s llist_entry; /* opaque type */
>Why the typedef? I'd just write:

class llist_entry ;

(My coding standards say to only use the keyword "class" for
forward declarations.)
struct llist_entry_s
{
llist_entry * next;
char * keyword;
char * value;

llist_entry() :next(0), keyword(0), value(0)
>There are two errors here: first, you didn't specify a return
type for the function,

It's a constructor; no return type.
A constructor is a "function" which has the same name as the class (or
struct) it belongs to. Here, the name of the struct is "llist_entry_s" and
the name of the supposed c-tor is "llist_entry". Those names are different
and therefore llist_entry_s::llist_entry() is not a constructor. It doesn't
matter that somewhere else there is a typedef for llist_entry. Any names
declared outside the scope of llist_entry_s may be overwritten by another
declaration inside that scope.

Heinz
Apr 8 '07 #7
On Apr 7, 9:56 pm, "Mike Wahler" <mkwah...@mkwahler.netwrote:
"James Kanze" <james.ka...@gmail.comwrote in message

news:11**********************@n59g2000hsh.googlegr oups.com...
On Apr 7, 9:40 pm, "2b|!2b==?" <r...@your.box.comwrote:
typedef struct llist_entry_s llist_entry; /* opaque type */
Why the typedef? I'd just write:
class llist_entry ;
(My coding standards say to only use the keyword "class" for
forward declarations.)
struct llist_entry_s
{
llist_entry * next;
char * keyword;
char * value;
llist_entry() :next(0), keyword(0), value(0)
There are two errors here: first, you didn't specify a return
type for the function,
It's a constructor; no return type.
No it's not. A constructor has the same name as the class.
This is apparently an attempt to declare a member function.
and second, you try to use an initializer
sequence which is only legal in constructors.
It is a ctor.
No it's not. That's why he's having problems.

--
James Kanze (Gabi Software) email: ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Apr 8 '07 #8
On Apr 7, 9:54 pm, "Mike Wahler" <mkwah...@mkwahler.netwrote:
"2b|!2b==?" <r...@your.box.comwrote in message
news:Lb******************************@bt.com...
typedef struct llist_entry_s llist_entry; /* opaque type */
struct llist_entry_s
{
llist_entry * next;
char * keyword;
char * value;
llist_entry() :next(0), keyword(0), value(0)
{
}
};
You don't say what compiler errors you get.
The above code compiles successfully for me with VC++.
It shouldn't. G++ says:
ctor.cc:16: error: ISO C++ forbids declaration of 'llist_entry'
with no type
ctor.cc:18: error: declaration of 'int
llist_entry_s::llist_entry()'
ctor.cc:8: error: changes meaning of 'llist_entry' from 'typedef
struct llist_entry_s llist_entry'
ctor.cc: In member function 'int llist_entry_s::llist_entry()':
ctor.cc:16: error: only constructors take base initializers
Which is what I'd expect.
BTW you don't need that typedef. You could write it
like this:
struct llist_entry
{
llist_entry * next;
char * keyword;
char * value;
llist_entry() :next(0), keyword(0), value(0)
{
}
};
That would be more idiomatic C++, of course.

--
James Kanze (Gabi Software) email: ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Apr 8 '07 #9

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

Similar topics

1
by: Alex Vinokur | last post by:
Here is some program in which static_cast is (wrongly) used instead of dynamic_cast. Is output of the program undefined or predicted? =========== C++ code : foo.cpp : BEGIN ===========...
1
by: Matthew Wilson | last post by:
I need to write a function crc(msg, len) that gets a char array of length len and then calculates the crc32 for the code. I don't understand what's going wrong in the code I have. It goes...
2
by: Tommy Vercetti | last post by:
In Visual Studio .NET 2003, I do the following 1) File->New->Project 2) Visual C++ Projects->.NET->Windows Forms Application 3) Project->Add New Item->C++ File 4) Clear the new C++ file and...
2
by: Phil Certain | last post by:
Hi, Relative newbie to .Net but experienced with classic ASP. I am trying to create a simple business object to contain commonly used functions. This is what I have done: 1 - Created a simple...
5
by: Jeff | last post by:
ASP.NET 2.0 This code crashes. It generate this error: Value cannot be null. Parameter name: type I've created some custom web.config settings and this crash is related to accessing theme...
7
by: =?Utf-8?B?UHJpdmF0ZQ==?= | last post by:
Hey, Can some one tell me about what's wrong with the following code and what is the solution with some meaningful correction ----------------------------- class Program { static void...
1
by: Varun Gupta | last post by:
PATH="/clocal/mqbrkrs/user/mqsiadm/sanjay/" MAIL_RECIPIENTS="rb903@dcx.com" Subject="File accessed in last minutes:" find "$PATH" -type f -amin -1 > temp.txt.$$ cat temp.txt.$$ | \ while read...
1
by: BSand0764 | last post by:
I'm getting an error that I can't seem to resolve. When I compile the Functor related logic in a test program, the files compile and execute properly (see Listing #1). However, when I...
4
by: (2b|!2b)==? | last post by:
template <typename T1, typename T2> struct MyDbInfo { MyDbInfo():m_pEnv(0), m_tran(0), m_db(0), m_idx(0) {} MyDbInfo(CDbEnv *env, DbTxn* tran, T1* db_ptr, T2 *idx_ptr):m_pEnv(env),...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.