Hi,
I'm using a glibc system header <sys/stat.h> which defines a C struct
'stat'. Furthermore, I'm using the struct 'dirent', defined in <dirent.h>.
Now, at one point in my code I'm holding an std::list of dirents:
std::list< dirent > mylist;
This works.
Now, I wanted to extend the list to hold pairs of dirent/stat:
std::list< std::pair< dirent, stat > > mynewlist;
Now, the compiler (g++ 3.3.4) says he doesn't know a type called 'stat'. So
I tried the C-style notation for instantiating structs:
std::list< std::pair< dirent, struct stat > > mynewlist;
This works. I find it rather odd that I can pass 'dirent' without a
preceding 'struct', but for 'stat' I have to do it the C way to calm the
compiler.
So, is there a rule of thumb in which cases I need the C-notation? Frankly I
was quite sure that you don't need it at all in C++.
Thanks in advance,
Matthias 3 1631
Matthias Käppler wrote: Hi,
I'm using a glibc system header <sys/stat.h> which defines a C struct 'stat'. Furthermore, I'm using the struct 'dirent', defined in <dirent.h>.
Now, at one point in my code I'm holding an std::list of dirents:
std::list< dirent > mylist;
This works.
Now, I wanted to extend the list to hold pairs of dirent/stat:
std::list< std::pair< dirent, stat > > mynewlist;
Now, the compiler (g++ 3.3.4) says he doesn't know a type called 'stat'. So I tried the C-style notation for instantiating structs:
std::list< std::pair< dirent, struct stat > > mynewlist;
This works. I find it rather odd that I can pass 'dirent' without a preceding 'struct', but for 'stat' I have to do it the C way to calm the compiler.
In this case, there is a function called AND a struct called stat.
i.e. func:
stat(const char*, stat*)
and
struct stat.
Matthias Käppler wrote in news:co*************@news.t-online.com in
comp.lang.c++: Hi,
I'm using a glibc system header <sys/stat.h> which defines a C struct 'stat'. Furthermore, I'm using the struct 'dirent', defined in <dirent.h>.
Now, at one point in my code I'm holding an std::list of dirents:
std::list< dirent > mylist;
This works.
Now, I wanted to extend the list to hold pairs of dirent/stat:
std::list< std::pair< dirent, stat > > mynewlist;
Now, the compiler (g++ 3.3.4) says he doesn't know a type called 'stat'. So I tried the C-style notation for instantiating structs:
std::list< std::pair< dirent, struct stat > > mynewlist;
This works. I find it rather odd that I can pass 'dirent' without a preceding 'struct', but for 'stat' I have to do it the C way to calm the compiler.
So, is there a rule of thumb in which cases I need the C-notation? Frankly I was quite sure that you don't need it at all in C++.
#include <list>
#include <utility>
struct dirent {};
struct stat {};
int stat; /* <- *note* */
typedef std::list< std::pair< dirent, struct stat > > list_t;
Remove the defenition "int stat;" and the "struct" should nolonger
be needed.
Its also possible that struct stat is undefined, in which case
you should also get "struct stat is an incomplete type" errors
or some such.
HTH.
Rob.
-- http://www.victim-prime.dsl.pipex.com/
"Matthias Käppler" <no****@digitalraid.com> wrote... I'm using a glibc system header <sys/stat.h> which defines a C struct 'stat'. Furthermore, I'm using the struct 'dirent', defined in <dirent.h>.
How are they defined there? Neither header is standard, so its contenst
and the definitions of those structures are unknown in C++.
Now, at one point in my code I'm holding an std::list of dirents:
std::list< dirent > mylist;
This works.
Now, I wanted to extend the list to hold pairs of dirent/stat:
std::list< std::pair< dirent, stat > > mynewlist;
Now, the compiler (g++ 3.3.4) says he doesn't know a type called 'stat'. So I tried the C-style notation for instantiating structs:
std::list< std::pair< dirent, struct stat > > mynewlist;
This works. I find it rather odd that I can pass 'dirent' without a preceding 'struct', but for 'stat' I have to do it the C way to calm the compiler.
So, is there a rule of thumb in which cases I need the C-notation? Frankly I was quite sure that you don't need it at all in C++.
That depends on how those things are defined. Another possibility is that
there is something else in your program called 'stat' and by adding the
keyword 'struct' you tell the compiler that you actually mean the type and
not something else.
Look in those headers, pull out the definitions for those structs into
a separate file, see what the difference is between them.
V This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sofia |
last post by:
My name is Sofia and I have for many years been running a personals site,
together with my partner, on a non-profit basis. The site is currently not
running due to us emigrating, but during its...
|
by: Robert Maas, see http://tinyurl.com/uh3t |
last post by:
System login message says PHP is available, so I tried this:
http://www.rawbw.com/~rem/HelloPlus/h.php
It doesn't work at all. Browser just shows the source.
What am I doing wrong?
|
by: Gregory Nans |
last post by:
hello,
i need some help to 'tree-ify' a string...
for example i have strings such as :
s = """A(here 's , B(A ) silly test) C(to show D(what kind) of stuff i
need))"""
and i need to...
|
by: JustSomeGuy |
last post by:
I need to write an new class derived from the list class.
This class stores data in the list to the disk if an object
that is added to the list is over 1K in size.
What methods of the std stl...
|
by: Bob.Henkel |
last post by:
I write this to tell you why we won't use postgresql even though we wish we
could at a large company. Don't get me wrong I love postgresql in many
ways and for many reasons , but fact is fact. If...
|
by: Michael R. Pierotti |
last post by:
Dim reg As New Regex("^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$")
Dim m As Match = reg.Match(txtIPAddress.Text)
If m.Success Then
'No need to do anything here
Else
MessageBox.Show("You need to enter a...
|
by: HotRod |
last post by:
I am new to this so please go easy. We currently have some students doing
some work on some web based tracking documents for us. They are currently
using VB .net to develop what we requested....
|
by: skumar434 |
last post by:
i need to store the data from a data base in to structure
.............the problem is like this ....suppose there is a data base
which stores the sequence no and item type etc ...but i need only...
|
by: Alan Mailer |
last post by:
A project I'm working on is going to use VB6 as a front end. The back
end is going to be pre-existing MS Access 2002 database tables which
already have records in them *but do not have any...
|
by: U S Contractors Offering Service A Non-profit |
last post by:
Brilliant technology helping those most in need Inbox
Reply
U S Contractors Offering Service A Non-profit
show details
10:37 pm (1 hour ago)
Brilliant technology helping those most in need ...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: ezappsrUS |
last post by:
Hi,
I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
| |