Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > PLEASE, PLEASE HELP - Compile time error message

Reply
Thread Tools

PLEASE, PLEASE HELP - Compile time error message

 
 
cpptutor2000@yahoo.com
Guest
Posts: n/a
 
      11-14-2007
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.

 
Reply With Quote
 
 
 
 
user923005
Guest
Posts: n/a
 
      11-14-2007
On Nov 14, 1:44 pm, "(E-Mail Removed)" <(E-Mail Removed)>
wrote:
> 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.

 
Reply With Quote
 
 
 
 
Walter Roberson
Guest
Posts: n/a
 
      11-14-2007
In article <(E-Mail Removed). com>,
http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:
>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 )
--
"Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us." -- Ecclesiastes
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      11-14-2007
(E-Mail Removed) wrote:
> 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.)

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Martin Ambuhl
Guest
Posts: n/a
 
      11-14-2007
(E-Mail Removed) wrote:
> 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.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to compile the following source code in VC6// I have error inVC++6 but compile ok in GCC fAnSKyer C++ 2 06-07-2009 07:57 AM
computation at compile time i.e. compile time functions usingtemplates Carter C++ 2 03-04-2009 06:43 PM
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments