| | |
Problem with Structs
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Sep 2008
Posts: 1,658
Reputation:
Solved Threads: 206
After compiling the code found here, I immediately got a number of errors. (Unfortunately, Beej is the starting point my instructor suggested to implement our FTP client's "minimal" commands, but that's another story). Anyway, I got rid of a few of them, then ran into this:
(It isn't actually on line 32 in Beej's guide, but it is one of the first lines of the main function - it's the one declaring the struct.)
So I looked up structs, and I saw that what Beej used is valid syntax for declaring a struct; however, the struct itself is not declared anywhere in the code. So I can only assume it is declared in a .h file or something, and I do not know how to get rid of that error. Any suggestions?
C Syntax (Toggle Plain Text)
client.c:32 - error: storage size of 'hints' isn't known
So I looked up structs, and I saw that what Beej used is valid syntax for declaring a struct; however, the struct itself is not declared anywhere in the code. So I can only assume it is declared in a .h file or something, and I do not know how to get rid of that error. Any suggestions?
Out.
•
•
Join Date: Sep 2008
Posts: 1,658
Reputation:
Solved Threads: 206
0
#2 Oct 30th, 2009
Well, after reading Salem's response on another site (funny to run into Salem's post on another board from around two years ago, heh):
I'm not sure how to proceed, but it is interesting. Doesn't that imply that one of my .h files that is included in my file contains an incomplete structure definition of addrinfo?
•
•
•
•
Originally Posted by Salem From Another Site
Well goo.c has the actual structure, so there is no way for foo.c to know what the members are.
All that goo.h does is basically confirm that a struct called st exists.
In foo.c, you could have
t_st *var;
but you still would not be able to access any members within that struct.
It is, in other words an incomplete type.
Incomplete types are very useful for implementing opaque interfaces. goo.h declares an opaque pointer, which any user just sees the pointer.
The actual content of the struct is private to goo.c.
It's what FILE* should be - all user code just passes around a FILE* without ever knowing what is behind it.
Out.
0
#3 Oct 30th, 2009
Hi, I compiled that file (client) and I am not getting any error . !!!!!!
I used cc compiler and compiled on the following OS
I used cc compiler and compiled on the following OS
C Syntax (Toggle Plain Text)
Linux mymachine 2.4.20-28.9.XFS1.3.1smp #1 SMP Mon Jan 5 13:20:15 CST 2004 i686 athlon i386 GNU/Linux
•
•
Join Date: Sep 2008
Posts: 1,658
Reputation:
Solved Threads: 206
0
#4 Oct 30th, 2009
What. . ?
I compiled with gcc -ansi -Wall client.c and I'm getting all sorts of errors. I'm not really sure what I could be doing wrong. I must be doing something really stupid though, because I don't think anyone else is having trouble with it. (Either that or nobody else is using it. . but it is an appropriate starting point for implementing an FTP client that sends commands such as "USER" and "PWD" to a server, isn't it?)
Edit: I compiled without the -ansi option and I got no errors. I guess its been so long since I've programmed in C that I completely forgot what the -ansi option does, but I can look that up. Thanks for dealing with my posts/stupidity
I compiled with gcc -ansi -Wall client.c and I'm getting all sorts of errors. I'm not really sure what I could be doing wrong. I must be doing something really stupid though, because I don't think anyone else is having trouble with it. (Either that or nobody else is using it. . but it is an appropriate starting point for implementing an FTP client that sends commands such as "USER" and "PWD" to a server, isn't it?)
Edit: I compiled without the -ansi option and I got no errors. I guess its been so long since I've programmed in C that I completely forgot what the -ansi option does, but I can look that up. Thanks for dealing with my posts/stupidity
Last edited by BestJewSinceJC; Oct 30th, 2009 at 2:44 am.
Out.
0
#7 Oct 30th, 2009
check the link:
http://tigcc.ticalc.org/doc/comopts.html
(search for ansi in it)
or read the gcc manual (man gcc).
The description is present there.
http://tigcc.ticalc.org/doc/comopts.html
(search for ansi in it)
or read the gcc manual (man gcc).
The description is present there.
•
•
Join Date: Sep 2008
Posts: 1,658
Reputation:
Solved Threads: 206
0
#8 Oct 30th, 2009
Ahh. That explains a lot. Thanks a lot, you've been extremely helpful.
P.S. for everyone's amusement, I've spent the last half hour trying to figure out why I kept getting "connection refused" from ftp.gl.umbc.edu and it turns out umbc.edu is completely down, so that might hold some answers.
Debugging hell.... haha
P.S. for everyone's amusement, I've spent the last half hour trying to figure out why I kept getting "connection refused" from ftp.gl.umbc.edu and it turns out umbc.edu is completely down, so that might hold some answers.
Debugging hell.... haha Out.
![]() |
Other Threads in the C Forum
- Previous Thread: How to put a full sentence into an array?
- Next Thread: C program for arrays
Views: 280 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays asterisks binarysearch calculate centimeter char command convert copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax directory dynamic executable fflush file fork forloop frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix problem probleminc program programming radix recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socketprograming spoonfeeding stack standard string strings structures student systemcall testautomation turboc unix user variable visualstudio voidmain() wab win32 windows.h






