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:

client.c:32 - error: storage size of 'hints' isn't known

(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?

Recommended Answers

All 7 Replies

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):

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.

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?

Hi, I compiled that file (client) and I am not getting any error . !!!!!!
I used cc compiler and compiled on the following OS

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

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


remove the -ansi option while compilation. Just do
gcc -Wall client.c

commented: Thanks! Wish I could give you more rep. +4

Yeah, I already did that on a whim, and thanks for compiling and helping me out - much appreciated. But what does "-ansi" actually mean? When I took C programming we just memorized to use that flag - we were told what it meant - but I forgot not and I see it nowhere online. Hmm.

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 and it turns out is completely down, so that might hold some answers. :) Debugging hell.... haha

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.