PLEASE, PLEASE HELP - Compile time error message

Discussion in 'C Programming' started by cpptutor2000@yahoo.com, Nov 14, 2007.

  1. Guest

    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.
     
    , Nov 14, 2007
    #1
    1. Advertising

  2. user923005 Guest

    On Nov 14, 1:44 pm, "" <>
    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.
     
    user923005, Nov 14, 2007
    #2
    1. Advertising

  3. In article <>,
    <> 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
     
    Walter Roberson, Nov 14, 2007
    #3
  4. 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) <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"
     
    Keith Thompson, Nov 14, 2007
    #4
  5. 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.
    >
     
    Martin Ambuhl, Nov 14, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. newbiecpp

    run-time vs compile-time

    newbiecpp, Sep 8, 2004, in forum: C++
    Replies:
    17
    Views:
    6,668
    Chris \( Val \)
    Sep 11, 2004
  2. flamesrock
    Replies:
    8
    Views:
    548
    Hendrik van Rooyen
    Nov 24, 2006
  3. Nagaraj
    Replies:
    1
    Views:
    913
    Lionel B
    Mar 1, 2007
  4. Carter
    Replies:
    2
    Views:
    527
    Carter
    Mar 4, 2009
  5. fAnSKyer
    Replies:
    2
    Views:
    566
    Alf P. Steinbach
    Jun 7, 2009
Loading...

Share This Page