Skip to contentSkip to conversation

warning: ‘struct ’ declared inside parameter list

DISCUSSION Fundu 3 participants 4 messages Feb 15, 2009 – Feb 17, 2009

lore
Share & tools
lore

Fundu

author
#0 lore raw

i'm running ubuntu 8.04 with gcc-4.2
and i'm getting

mb_con.h:43: warning: ‘struct query_resp’ declared inside parameter list
mb_con.h:43: warning: its scope is only this definition or declaration, which is probably not what you want

here's a snippet of how .h file looks

struct query_resp_type
{
int type;
} query_resp;

void send_req(struct query_resp* resp);

what i don't understand is why this warning when i have declared the struct before the function in the header.

what am i missing ?

thanks in advance !

--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw

"None are more hopelessly enslaved than those who falsely believe they are free."
--Goethe

"Freedom is living without government coercion."

                   --Ron Paul (www.ronpaul2008.com)
Quoted 6 lines · Fundu

i'm running ubuntu 8.04 with gcc-4.2
and i'm getting

mb_con.h:43: warning: 'struct query_resp' declared inside parameter list
mb_con.h:43: warning: its scope is only this definition or declaration, which is probably not what you want

Quoted 6 lines

here's a snippet of how .h file looks

struct query_resp_type
{
int type;
} query_resp;

};

Quoted 2 lines

void send_req(struct query_resp* resp);

void send_req(struct query_resp_type* resp);

Quoted 16 lines

what i don't understand is why this warning when i have declared the struct before the function in the header.

what am i missing ?

thanks in advance !

--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to Fundu
Quoted 11 lines · Fundu

i'm running ubuntu 8.04 with gcc-4.2
and i'm getting

mb_con.h:43: warning: ‘struct query_resp’ declared inside parameter list
mb_con.h:43: warning: its scope is only this definition or declaration, which is probably not what you want here's a snippet of how .h file looks

struct query_resp_type
{
int type;
} query_resp;

you defined here _both a type and a variable_.
this should not be done inside a .h file...

maybe you expected to redefine a type, and forgot to 'typedef' ? ==
struct query_resp_type {
int type;
};

typedef struct query_resp_type query_resp;
==
after such a typedef, you will be able to use type 'query_resp' (note that 'struct' is not part of the type name)

Quoted 1 line

void send_req(struct query_resp* resp);

wrong. type 'struct query_resp' does not exist.
but 'struct query_resp_type' does.

Quoted 3 lines

what i don't understand is why this warning when i have declared the struct before the function in the header.

typo issue.

Quoted 1 line

what am i missing ?

see above

Quoted 2 lines

thanks in advance !

--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#3 lore raw

thanks Ben !

Quoted 46 lines · ben

From: ben <[email protected]>
Subject: Re: warning: ‘struct ’ declared inside parameter list
To: [email protected]
Date: Monday, February 16, 2009, 9:03 AM

Quoted 4 lines · Fundu

i'm running ubuntu 8.04 with gcc-4.2
and i'm getting

mb_con.h:43: warning: ‘struct query_resp’ declared

inside parameter list

Quoted 1 line

mb_con.h:43: warning: its scope is only this

definition or declaration, which is probably not what you want

Quoted 6 lines

here's a snippet of how .h file looks

struct query_resp_type
{
int type;
} query_resp;

you defined here _both a type and a variable_. this should not be done inside a .h file...

maybe you expected to redefine a type, and forgot to 'typedef' ?
==
struct query_resp_type {
int type;
};

typedef struct query_resp_type query_resp; ==
after such a typedef, you will be able to use type 'query_resp'
(note that 'struct' is not part of the type name)

Quoted 1 line

void send_req(struct query_resp* resp);

wrong. type 'struct query_resp' does not exist. but 'struct query_resp_type' does.

Quoted 3 lines

what i don't understand is why this warning when i

have declared the struct before the function in the header. typo issue.

Quoted 1 line

what am i missing ?

see above

Quoted 8 lines
Quoted 2 lines

thanks in advance !

--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html