PLEASE, PLEASE HELP - Compile time error message

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cpptutor2000@yahoo.com

    PLEASE, PLEASE HELP - Compile time error message

    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 'SohoFirewallMo del' is enabled */
    BOOL bAllowOutbound; /* only used
    if 'SohoFirewallMo del' is enabled */
    ULONG SessionTimeout; /* override
    the session timeout value, in minutes */

    ULONG Action;
    BOOL bAnyService;
    char
    ServiceName[BOND_SERVICE_NA ME_SIZE ];

    BOOL bSrcAllIpAddrs;
    BOND_ADDRESS_PO OL SrcIpAddrPool;
    BOOL bDstAllIpAddrs;
    BOND_ADDRESS_PO OL DstIpAddrPool;

    BOOL bBwmEnabled;
    ULONG BwmType;
    ULONG GuaBandwidthInK bps;
    ULONG MaxBandwidthInK bps;
    ULONG Priority;

    BOND_ADDRESS_GR OUP SrcIpAddrGroup; /* this field
    is for internal use only */
    BOND_ADDRESS_GR OUP DstIpAddrGroup; /* this field
    is for internal use only */
    }
    FIREWALL_RULE_I NFO, *PFIREWALL_RULE _INFO;

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

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

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

  • user923005

    #2
    Re: PLEASE, PLEASE HELP - Compile time error message

    On Nov 14, 1:44 pm, "cpptutor2...@y ahoo.com" <cpptutor2...@y ahoo.com>
    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 'SohoFirewallMo del' is enabled */
    BOOL bAllowOutbound; /* only used
    if 'SohoFirewallMo del' is enabled */
    ULONG SessionTimeout; /* override
    the session timeout value, in minutes */
    >
    ULONG Action;
    BOOL bAnyService;
    char
    ServiceName[BOND_SERVICE_NA ME_SIZE ];
    >
    BOOL bSrcAllIpAddrs;
    BOND_ADDRESS_PO OL SrcIpAddrPool;
    BOOL bDstAllIpAddrs;
    BOND_ADDRESS_PO OL DstIpAddrPool;
    >
    BOOL bBwmEnabled;
    ULONG BwmType;
    ULONG GuaBandwidthInK bps;
    ULONG MaxBandwidthInK bps;
    ULONG Priority;
    >
    BOND_ADDRESS_GR OUP SrcIpAddrGroup; /* this field
    is for internal use only */
    BOND_ADDRESS_GR OUP DstIpAddrGroup; /* this field
    is for internal use only */}
    >
    FIREWALL_RULE_I NFO, *PFIREWALL_RULE _INFO;
    >
    I get the following compile time error message, while compiling a
    function that clones a FIREWALL_RULE_I NFO struct.
    >
    request for member `MaxBandwidthIn Kbps' 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_PO OL,
    BOND_SERVICE_NA ME_SIZE, BOND_ADDRESS_GR OUP

    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.

    Comment

    • Walter Roberson

      #3
      Re: PLEASE, PLEASE HELP - Compile time error message

      In article <1195076660.789 132.216870@19g2 000hsx.googlegr oups.com>,
      cpptutor2000@ya hoo.com <cpptutor2000@y ahoo.comwrote:
      >Could someone please help me? I have the following C struct.
      >typedef struct
      >_FIREWALL_RULE _INFO
      >{
      ULONG Precedence;
      [...]
      ULONG MaxBandwidthInK bps;
      >}
      >FIREWALL_RULE_ INFO, *PFIREWALL_RULE _INFO;
      >I get the following compile time error message, while compiling a
      >function that clones a FIREWALL_RULE_I NFO struct.
      >request for member `MaxBandwidthIn Kbps' in something not a structure
      >or union
      Perhaps at that point, you have something like

      thisthing.MaxBa ndwidthInKbps

      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->MaxBandwidthIn Kbps instead of
      thisthing.MaxBa ndwidthInKbps

      (Given your comment about the function cloning the struct, your
      code might have thisthing->MaxBandwidthIn Kbps
      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)->MaxBandwidthIn Kbps )
      --
      "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

      Comment

      • Keith Thompson

        #4
        Re: PLEASE, PLEASE HELP - Compile time error message

        cpptutor2000@ya hoo.com 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 'SohoFirewallMo del' is enabled */
        BOOL bAllowOutbound; /* only used
        if 'SohoFirewallMo del' is enabled */
        ULONG SessionTimeout; /* override
        the session timeout value, in minutes */
        >
        ULONG Action;
        BOOL bAnyService;
        char
        ServiceName[BOND_SERVICE_NA ME_SIZE ];
        >
        BOOL bSrcAllIpAddrs;
        BOND_ADDRESS_PO OL SrcIpAddrPool;
        BOOL bDstAllIpAddrs;
        BOND_ADDRESS_PO OL DstIpAddrPool;
        >
        BOOL bBwmEnabled;
        ULONG BwmType;
        ULONG GuaBandwidthInK bps;
        ULONG MaxBandwidthInK bps;
        ULONG Priority;
        >
        BOND_ADDRESS_GR OUP SrcIpAddrGroup; /* this field
        is for internal use only */
        BOND_ADDRESS_GR OUP DstIpAddrGroup; /* this field
        is for internal use only */
        }
        FIREWALL_RULE_I NFO, *PFIREWALL_RULE _INFO;
        >
        I get the following compile time error message, while compiling a
        function that clones a FIREWALL_RULE_I NFO struct.
        >
        request for member `MaxBandwidthIn Kbps' 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_I NFO 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 ".MaxBandwidthI nKbps" to it.
        For example:

        PFIREWALL_RULE_ INFO ptr; /* ptr is a pointer to struct */
        ...
        ptr.MaxBandwidt hInKbps /* ptr is a pointer, not a struct */

        Either the prefix needs to be of type FIREWALL_RULE_I NFO, 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_Keit h) kst-u@mib.org <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"

        Comment

        • Martin Ambuhl

          #5
          Re: PLEASE, PLEASE HELP - Compile time error message

          cpptutor2000@ya hoo.com 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_Po ol, Bond_Address_Gr oup;
          #define BOND_SERVICE_NA ME_SIZE 1

          typedef struct
          {
          unsigned long Precedence;
          bool bEnabled;
          bool bLoggingEnabled ;
          bool bAllowFragments ;
          bool bAllowInbound; /* only used if 'SohoFirewallMo del' is
          enabled */
          bool bAllowOutbound; /* only used if 'SohoFirewallMo del' is
          enabled */
          unsigned long SessionTimeout; /* override the session timeout
          value, in minutes */
          unsigned long Action;
          bool bAnyService;
          char ServiceName[BOND_SERVICE_NA ME_SIZE];
          bool bSrcAllIpAddrs;
          Bond_Address_Po ol SrcIpAddrPool;
          bool bDstAllIpAddrs;
          Bond_Address_Po ol DstIpAddrPool;
          bool bBwmEnabled;
          unsigned long BwmType;
          unsigned long GuaBandwidthInK bps;
          unsigned long MaxBandwidthInK bps;
          unsigned long Priority;
          Bond_Address_Gr oup SrcIpAddrGroup; /* this field is for internal
          use only */
          Bond_Address_Gr oup DstIpAddrGroup; /* this field is for internal
          use only */
          }
          Firewall_Rule_I nfo;

          Firewall_Rule_I nfo *clone_firewall _rule(Firewall_ Rule_Info * in)
          {
          Firewall_Rule_I nfo *out;
          if ((out = malloc(sizeof *out)))
          memcpy(out, in, sizeof *out);
          return out;
          }

          int main(void)
          {
          Firewall_Rule_I nfo original = {.MaxBandwidthI nKbps = 372586 }, *new;
          new = clone_firewall_ rule(&original) ;
          printf("MaxBand widthInKbps in original structure: %lu\n"
          "MaxBandwidthIn Kbps in copy (*new) structure: %lu\n",
          original.MaxBan dwidthInKbps, (*new).MaxBandw idthInKbps);
          free(new);
          return 0;
          }

          [output]
          MaxBandwidthInK bps in original structure: 372586
          MaxBandwidthInK bps 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 'SohoFirewallMo del' is enabled */
          BOOL bAllowOutbound; /* only used
          if 'SohoFirewallMo del' is enabled */
          ULONG SessionTimeout; /* override
          the session timeout value, in minutes */
          >
          ULONG Action;
          BOOL bAnyService;
          char
          ServiceName[BOND_SERVICE_NA ME_SIZE ];
          >
          BOOL bSrcAllIpAddrs;
          BOND_ADDRESS_PO OL SrcIpAddrPool;
          BOOL bDstAllIpAddrs;
          BOND_ADDRESS_PO OL DstIpAddrPool;
          >
          BOOL bBwmEnabled;
          ULONG BwmType;
          ULONG GuaBandwidthInK bps;
          ULONG MaxBandwidthInK bps;
          ULONG Priority;
          >
          BOND_ADDRESS_GR OUP SrcIpAddrGroup; /* this field
          is for internal use only */
          BOND_ADDRESS_GR OUP DstIpAddrGroup; /* this field
          is for internal use only */
          }
          FIREWALL_RULE_I NFO, *PFIREWALL_RULE _INFO;
          >
          I get the following compile time error message, while compiling a
          function that clones a FIREWALL_RULE_I NFO struct.
          >
          request for member `MaxBandwidthIn Kbps' in something not a structure
          or union
          >
          Could someone please point out what I might be doing wrong? Thanks in
          advance for your help.
          >

          Comment

          Working...