Arthur Tumanyan wrote:
> Hi everyone!
> I have some problems with struct size defination and malloc()/free() .
> 
> Here is my code:
> //-----------------------shaga.h----------------------
> #define UNAME_MAXLEN 8
> #define PWD_MAXLEN 8
> #define Q_LINE_MAXLEN 512
> 
> enum _logtype{ shaga,syslog };
> enum _onoff{ on,off };
> 
> struct _shaga{
>       in_addr_t       db_host;
>       u_short         db_port;
>       char            db_name[Q_LINE_MAXLEN];
>       char            db_user[UNAME_MAXLEN];
>       char            db_pwd[PWD_MAXLEN];
>       const           char *logfile[Q_LINE_MAXLEN];
>       u_short         maxusers;
>       _logtype        logtype;
>       _onoff          enable_shaga;
> 
> }
> struct Config{
> 
>       _shaga  shaga;
> 
> gcc -Wall shaga.c -o shaga ,then i get following error messages:
> 
> shaga.c: In function `main':
> shaga.c:18: error: storage size of 'myConfig' isn't known
> 
> What does this mean? I think it is because  of the compiler don't know the
> struct size.Am i wrong?

I'm pretty sure the problem is that you have named the file with a .c 
extension but you are using, IIRC, C++ specific stuff in the .h file.  Try:

struct Config{
        struct _shaga   shaga;
}

Instead.  (Notice the extra 'struct').  Alternatively, rename the file 
with a .cpp extension.

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to