PLEASE, PLEASE HELP - Compile time error message

C

cpptutor2000

Could someone please help me? I have the following C struct.
typedef struct
_FIREWALL_RULE_INFO
{
ULONG Precedence;
BOOL bEnabled;
BOOL bLoggingEnabled;
BOOL bAllowFragments;
BOOL bAllowInbound; /* only used
if 'SohoFirewallModel' is enabled */
BOOL bAllowOutbound; /* only used
if 'SohoFirewallModel' is enabled */
ULONG SessionTimeout; /* override
the session timeout value, in minutes */

ULONG Action;
BOOL bAnyService;
char
ServiceName[BOND_SERVICE_NAME_SIZE ];

BOOL bSrcAllIpAddrs;
BOND_ADDRESS_POOL SrcIpAddrPool;
BOOL bDstAllIpAddrs;
BOND_ADDRESS_POOL DstIpAddrPool;

BOOL bBwmEnabled;
ULONG BwmType;
ULONG GuaBandwidthInKbps;
ULONG MaxBandwidthInKbps;
ULONG Priority;

BOND_ADDRESS_GROUP SrcIpAddrGroup; /* this field
is for internal use only */
BOND_ADDRESS_GROUP DstIpAddrGroup; /* this field
is for internal use only */
}
FIREWALL_RULE_INFO, *PFIREWALL_RULE_INFO;

I get the following compile time error message, while compiling a
function that clones a FIREWALL_RULE_INFO struct.

request for member `MaxBandwidthInKbps' in something not a structure
or union

Could someone please point out what I might be doing wrong? Thanks in
advance for your help.
 
U

user923005

Could someone please help me? I have the following C struct.
typedef struct
_FIREWALL_RULE_INFO
{
ULONG Precedence;
BOOL bEnabled;
BOOL bLoggingEnabled;
BOOL bAllowFragments;
BOOL bAllowInbound; /* only used
if 'SohoFirewallModel' is enabled */
BOOL bAllowOutbound; /* only used
if 'SohoFirewallModel' is enabled */
ULONG SessionTimeout; /* override
the session timeout value, in minutes */

ULONG Action;
BOOL bAnyService;
char
ServiceName[BOND_SERVICE_NAME_SIZE ];

BOOL bSrcAllIpAddrs;
BOND_ADDRESS_POOL SrcIpAddrPool;
BOOL bDstAllIpAddrs;
BOND_ADDRESS_POOL DstIpAddrPool;

BOOL bBwmEnabled;
ULONG BwmType;
ULONG GuaBandwidthInKbps;
ULONG MaxBandwidthInKbps;
ULONG Priority;

BOND_ADDRESS_GROUP SrcIpAddrGroup; /* this field
is for internal use only */
BOND_ADDRESS_GROUP DstIpAddrGroup; /* this field
is for internal use only */}

FIREWALL_RULE_INFO, *PFIREWALL_RULE_INFO;

I get the following compile time error message, while compiling a
function that clones a FIREWALL_RULE_INFO struct.

request for member `MaxBandwidthInKbps' in something not a structure
or union

Could someone please point out what I might be doing wrong? Thanks in
advance for your help.

Missing are definitions for BOOL, ULONG, BOND_ADDRESS_POOL,
BOND_SERVICE_NAME_SIZE, BOND_ADDRESS_GROUP

Missing is the bit of code where you try to use it.

But, upon donning my Karnak hat, I can easily see that you have made a
mistake in your code somewhere.
 
W

Walter Roberson

Could someone please help me? I have the following C struct.
typedef struct
_FIREWALL_RULE_INFO
{
ULONG Precedence; [...]
ULONG MaxBandwidthInKbps;
}
FIREWALL_RULE_INFO, *PFIREWALL_RULE_INFO;

I get the following compile time error message, while compiling a
function that clones a FIREWALL_RULE_INFO struct.
request for member `MaxBandwidthInKbps' in something not a structure
or union

Perhaps at that point, you have something like

thisthing.MaxBandwidthInKbps

and it is complaining because thisthing is not a structure or union.
If, for example, thisthing was a -pointer- to a structure then
you would use thisthing->MaxBandwidthInKbps instead of
thisthing.MaxBandwidthInKbps

(Given your comment about the function cloning the struct, your
code might have thisthing->MaxBandwidthInKbps
except that instead of thisthing being a pointer to the
structure, you have it as a pointer to a pointer to the structure,
needing (*thisthing)->MaxBandwidthInKbps )
 
K

Keith Thompson

Could someone please help me? I have the following C struct.
typedef struct
_FIREWALL_RULE_INFO
{
ULONG Precedence;
BOOL bEnabled;
BOOL bLoggingEnabled;
BOOL bAllowFragments;
BOOL bAllowInbound; /* only used
if 'SohoFirewallModel' is enabled */
BOOL bAllowOutbound; /* only used
if 'SohoFirewallModel' is enabled */
ULONG SessionTimeout; /* override
the session timeout value, in minutes */

ULONG Action;
BOOL bAnyService;
char
ServiceName[BOND_SERVICE_NAME_SIZE ];

BOOL bSrcAllIpAddrs;
BOND_ADDRESS_POOL SrcIpAddrPool;
BOOL bDstAllIpAddrs;
BOND_ADDRESS_POOL DstIpAddrPool;

BOOL bBwmEnabled;
ULONG BwmType;
ULONG GuaBandwidthInKbps;
ULONG MaxBandwidthInKbps;
ULONG Priority;

BOND_ADDRESS_GROUP SrcIpAddrGroup; /* this field
is for internal use only */
BOND_ADDRESS_GROUP DstIpAddrGroup; /* this field
is for internal use only */
}
FIREWALL_RULE_INFO, *PFIREWALL_RULE_INFO;

I get the following compile time error message, while compiling a
function that clones a FIREWALL_RULE_INFO struct.

request for member `MaxBandwidthInKbps' in something not a structure
or union

Could someone please point out what I might be doing wrong? Thanks in
advance for your help.

What you're doing wrong is failing to show us the code that causes the error.
You say you have a function that "clones" (what exactly does that mean?) a
FIREWALL_RULE_INFO struct. The compiler isn't complaining about the function;
it's complaining about some specific construct in the function. And it's
telling you (by showing the line number) exactly which construct it doesn't like
-- but you're not telling us.

Always show the *exact* code that produces an error, along with the *exact*
error message. Copy-and-paste both; don't try to summarize or re-type.

The above declares a type "struct _FIREWALL_RULE_INFO" (which is unwise;
identifiers starting with "_" and an uppercase letter are reserved to the
implementation). It declares "FIREWALL_RULE_INFO" as an alias for this type,
and "PFIREWALL_RULE_INFO" for "pointer to struct _FIREWALL_RULE_INFO".

My guess (and it's only a guess) is that you have something of type
"PFIREWALL_RULE_INFO", and you're trying to apply ".MaxBandwidthInKbps" to it.
For example:

PFIREWALL_RULE_INFO ptr; /* ptr is a pointer to struct */
...
ptr.MaxBandwidthInKbps /* ptr is a pointer, not a struct */

Either the prefix needs to be of type FIREWALL_RULE_INFO, or you need to use the
"->" operator instead of the "." operator.

This illustrates one reason why it's almost always a bad idea to use a typedef
for a pointer type. If you simply declared your pointers as type
"*FIREWALL_RULE_INFO", it would be more obvious that they're pointers.

(I also question the wisdom of a typedef like "ULONG". If you mean unsigned
long, just use unsigned long. If there's any possibility that ULONG could be
something other than unsigned long, then ULONG is a lousy name.)
 
M

Martin Ambuhl

Could someone please help me? I have the following C struct.
[OP's code is quoted at EOM]
I have rewritten your struct into C and provided both a clone function
and a main() driver. Compare your code (which you have kept secret) to
these.
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

typedef unsigned Bond_Address_Pool, Bond_Address_Group;
#define BOND_SERVICE_NAME_SIZE 1

typedef struct
{
unsigned long Precedence;
bool bEnabled;
bool bLoggingEnabled;
bool bAllowFragments;
bool bAllowInbound; /* only used if 'SohoFirewallModel' is
enabled */
bool bAllowOutbound; /* only used if 'SohoFirewallModel' is
enabled */
unsigned long SessionTimeout; /* override the session timeout
value, in minutes */
unsigned long Action;
bool bAnyService;
char ServiceName[BOND_SERVICE_NAME_SIZE];
bool bSrcAllIpAddrs;
Bond_Address_Pool SrcIpAddrPool;
bool bDstAllIpAddrs;
Bond_Address_Pool DstIpAddrPool;
bool bBwmEnabled;
unsigned long BwmType;
unsigned long GuaBandwidthInKbps;
unsigned long MaxBandwidthInKbps;
unsigned long Priority;
Bond_Address_Group SrcIpAddrGroup; /* this field is for internal
use only */
Bond_Address_Group DstIpAddrGroup; /* this field is for internal
use only */
}
Firewall_Rule_Info;

Firewall_Rule_Info *clone_firewall_rule(Firewall_Rule_Info * in)
{
Firewall_Rule_Info *out;
if ((out = malloc(sizeof *out)))
memcpy(out, in, sizeof *out);
return out;
}

int main(void)
{
Firewall_Rule_Info original = {.MaxBandwidthInKbps = 372586 }, *new;
new = clone_firewall_rule(&original);
printf("MaxBandwidthInKbps in original structure: %lu\n"
"MaxBandwidthInKbps in copy (*new) structure: %lu\n",
original.MaxBandwidthInKbps, (*new).MaxBandwidthInKbps);
free(new);
return 0;
}

[output]
MaxBandwidthInKbps in original structure: 372586
MaxBandwidthInKbps in copy (*new) structure: 372586



[OP's code, etc.]
typedef struct
_FIREWALL_RULE_INFO
{
ULONG Precedence;
BOOL bEnabled;
BOOL bLoggingEnabled;
BOOL bAllowFragments;
BOOL bAllowInbound; /* only used
if 'SohoFirewallModel' is enabled */
BOOL bAllowOutbound; /* only used
if 'SohoFirewallModel' is enabled */
ULONG SessionTimeout; /* override
the session timeout value, in minutes */

ULONG Action;
BOOL bAnyService;
char
ServiceName[BOND_SERVICE_NAME_SIZE ];

BOOL bSrcAllIpAddrs;
BOND_ADDRESS_POOL SrcIpAddrPool;
BOOL bDstAllIpAddrs;
BOND_ADDRESS_POOL DstIpAddrPool;

BOOL bBwmEnabled;
ULONG BwmType;
ULONG GuaBandwidthInKbps;
ULONG MaxBandwidthInKbps;
ULONG Priority;

BOND_ADDRESS_GROUP SrcIpAddrGroup; /* this field
is for internal use only */
BOND_ADDRESS_GROUP DstIpAddrGroup; /* this field
is for internal use only */
}
FIREWALL_RULE_INFO, *PFIREWALL_RULE_INFO;

I get the following compile time error message, while compiling a
function that clones a FIREWALL_RULE_INFO struct.

request for member `MaxBandwidthInKbps' in something not a structure
or union

Could someone please point out what I might be doing wrong? Thanks in
advance for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top