Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error C2678

error C2678

Scheduled Pinned Locked Moved C / C++ / MFC
linuxregexhelplearning
30 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    Why would you change it to a struct, it only requires a single integer variable to hold all the flags.

    int flags = FILE_READONLY | FILE_HIDDEN;
    flags |= FILE_SYSTEM;

    _ Offline
    _ Offline
    _Flaviu
    wrote on last edited by
    #12

    I am afraid that I cannot change that enum into #defines, because I have:

    na->flags |= flag;

    where

    FILE_FLAGS flag;

    and na is struct level1, and inside this level1 struct, I have

    struct level1
    {
    FILE_FLAGS flags;
    ....
    };

    I have entered in some deadlock ? Please help me to solve this error ...

    V L 2 Replies Last reply
    0
    • _ _Flaviu

      I am afraid that I cannot change that enum into #defines, because I have:

      na->flags |= flag;

      where

      FILE_FLAGS flag;

      and na is struct level1, and inside this level1 struct, I have

      struct level1
      {
      FILE_FLAGS flags;
      ....
      };

      I have entered in some deadlock ? Please help me to solve this error ...

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #13

      Try to declare both flags and flag as int

      _ 1 Reply Last reply
      0
      • V Victor Nijegorodov

        Try to declare both flags and flag as int

        _ Offline
        _ Offline
        _Flaviu
        wrote on last edited by
        #14

        Yes, but FILE_FLAGS is enum with int values ...

        V 1 Reply Last reply
        0
        • _ _Flaviu

          Yes, but FILE_FLAGS is enum with int values ...

          V Offline
          V Offline
          Victor Nijegorodov
          wrote on last edited by
          #15

          Then, as Richard already suggested replace this enum with a set of #define.

          _ 1 Reply Last reply
          0
          • V Victor Nijegorodov

            Then, as Richard already suggested replace this enum with a set of #define.

            _ Offline
            _ Offline
            _Flaviu
            wrote on last edited by
            #16

            Agree, but that enum is a part of another struct ... so, how can I put as part of a struct several #defines ?

            1 Reply Last reply
            0
            • _ _Flaviu

              I am afraid that I cannot change that enum into #defines, because I have:

              na->flags |= flag;

              where

              FILE_FLAGS flag;

              and na is struct level1, and inside this level1 struct, I have

              struct level1
              {
              FILE_FLAGS flags;
              ....
              };

              I have entered in some deadlock ? Please help me to solve this error ...

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #17

              Of course you can change it to #defines. The definition of FILE_FLAGS then becomes an int type. And then the rest of the code should compile correctly.

              _ 1 Reply Last reply
              0
              • L Lost User

                Of course you can change it to #defines. The definition of FILE_FLAGS then becomes an int type. And then the rest of the code should compile correctly.

                _ Offline
                _ Offline
                _Flaviu
                wrote on last edited by
                #18

                I am not get something, so forgive me. I have moved those enum values as #defines, but of course, now I get error from struct: doesn't know who is FILE_FLAGS flags; from level1 struct.

                /*
                typedef enum {
                FILE_READONLY = 0x00000001,
                FILE_HIDDEN = 0x00000002,
                FILE_SYSTEM = 0x00000004,

                FILE\_DIRECTORY = 0x00000010,
                FILE\_ARCHIVE = 0x00000020,
                FILE\_DEVICE = 0x00000040,
                FILE\_NORMAL = 0x00000080,
                
                FILE\_TEMPORARY = 0x00000100,
                

                ....
                .....

                }FILE_FLAGS;
                */

                #define FILE_READONLY = 0x00000001
                #define FILE_HIDDEN = 0x00000002
                #define FILE_SYSTEM = 0x00000004

                of course, FILE_FLAGS enum has disappeared ... obviously, I don't understood something ... but what ?

                struct level1
                {
                FILE_FLAGS flags; // <-- error
                ....
                };

                V L 2 Replies Last reply
                0
                • _ _Flaviu

                  I am not get something, so forgive me. I have moved those enum values as #defines, but of course, now I get error from struct: doesn't know who is FILE_FLAGS flags; from level1 struct.

                  /*
                  typedef enum {
                  FILE_READONLY = 0x00000001,
                  FILE_HIDDEN = 0x00000002,
                  FILE_SYSTEM = 0x00000004,

                  FILE\_DIRECTORY = 0x00000010,
                  FILE\_ARCHIVE = 0x00000020,
                  FILE\_DEVICE = 0x00000040,
                  FILE\_NORMAL = 0x00000080,
                  
                  FILE\_TEMPORARY = 0x00000100,
                  

                  ....
                  .....

                  }FILE_FLAGS;
                  */

                  #define FILE_READONLY = 0x00000001
                  #define FILE_HIDDEN = 0x00000002
                  #define FILE_SYSTEM = 0x00000004

                  of course, FILE_FLAGS enum has disappeared ... obviously, I don't understood something ... but what ?

                  struct level1
                  {
                  FILE_FLAGS flags; // <-- error
                  ....
                  };

                  V Offline
                  V Offline
                  Victor Nijegorodov
                  wrote on last edited by
                  #19

                  _Flaviu wrote:

                  struct level1 { FILE_FLAGS flags; // <-- error .... };

                  Try

                  struct level1
                  {
                  int flags; // <-- error
                  ....
                  };

                  _ 1 Reply Last reply
                  0
                  • V Victor Nijegorodov

                    _Flaviu wrote:

                    struct level1 { FILE_FLAGS flags; // <-- error .... };

                    Try

                    struct level1
                    {
                    int flags; // <-- error
                    ....
                    };

                    _ Offline
                    _ Offline
                    _Flaviu
                    wrote on last edited by
                    #20

                    Ok, but even flag is comming as function parameter, just like this:

                    static void SomeFunction(level1* na, FILE_FLAGS flag)
                    {
                    ....
                    na->flags |= ~flag;
                    ....
                    }

                    So, I guess I cannot give up FILE_FLAGS enum ... don't I ?

                    V 1 Reply Last reply
                    0
                    • _ _Flaviu

                      Ok, but even flag is comming as function parameter, just like this:

                      static void SomeFunction(level1* na, FILE_FLAGS flag)
                      {
                      ....
                      na->flags |= ~flag;
                      ....
                      }

                      So, I guess I cannot give up FILE_FLAGS enum ... don't I ?

                      V Offline
                      V Offline
                      Victor Nijegorodov
                      wrote on last edited by
                      #21

                      Change this parameter to be

                      static void SomeFunction(level1* na, int flag)
                      {

                      1 Reply Last reply
                      0
                      • _ _Flaviu

                        I am not get something, so forgive me. I have moved those enum values as #defines, but of course, now I get error from struct: doesn't know who is FILE_FLAGS flags; from level1 struct.

                        /*
                        typedef enum {
                        FILE_READONLY = 0x00000001,
                        FILE_HIDDEN = 0x00000002,
                        FILE_SYSTEM = 0x00000004,

                        FILE\_DIRECTORY = 0x00000010,
                        FILE\_ARCHIVE = 0x00000020,
                        FILE\_DEVICE = 0x00000040,
                        FILE\_NORMAL = 0x00000080,
                        
                        FILE\_TEMPORARY = 0x00000100,
                        

                        ....
                        .....

                        }FILE_FLAGS;
                        */

                        #define FILE_READONLY = 0x00000001
                        #define FILE_HIDDEN = 0x00000002
                        #define FILE_SYSTEM = 0x00000004

                        of course, FILE_FLAGS enum has disappeared ... obviously, I don't understood something ... but what ?

                        struct level1
                        {
                        FILE_FLAGS flags; // <-- error
                        ....
                        };

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #22

                        Add this line somewhere before the first reference to FILE_FLAGS :

                        typedef int FILE_FLAGS;

                        _ 1 Reply Last reply
                        0
                        • L Lost User

                          Add this line somewhere before the first reference to FILE_FLAGS :

                          typedef int FILE_FLAGS;

                          _ Offline
                          _ Offline
                          _Flaviu
                          wrote on last edited by
                          #23

                          I encounter another error if I made these modifications:

                          data->com = na->flags & ATTR_IS_COMPRESSED; // <-- error C2059: syntax error : '='

                          (where data->com is int) because now ATTR_IS_COMPRESSED is #define, not part of enum FILE_FLAGS ...

                          L 2 Replies Last reply
                          0
                          • _ _Flaviu

                            I encounter another error if I made these modifications:

                            data->com = na->flags & ATTR_IS_COMPRESSED; // <-- error C2059: syntax error : '='

                            (where data->com is int) because now ATTR_IS_COMPRESSED is #define, not part of enum FILE_FLAGS ...

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #24

                            What is data->com?

                            _Flaviu wrote:

                            because now ATTR_IS_COMPRESSED is #define, not part of enum FILE_FLAGS

                            That is not the reason. I can only assume that you have done a partial change and some parts of your code are still incorrect. If you still have the FILE_FLAGS enum then it is going to cause problems. It would probably help if you showed all the code portions that are connected. It is difficult to be certain of the answers when looking at only a single line of code.

                            1 Reply Last reply
                            0
                            • _ _Flaviu

                              I encounter another error if I made these modifications:

                              data->com = na->flags & ATTR_IS_COMPRESSED; // <-- error C2059: syntax error : '='

                              (where data->com is int) because now ATTR_IS_COMPRESSED is #define, not part of enum FILE_FLAGS ...

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #25

                              I still cannot see enough information. Please provide what I previously requested and reply to this message. Please do not email me personally.

                              _ 3 Replies Last reply
                              0
                              • L Lost User

                                I still cannot see enough information. Please provide what I previously requested and reply to this message. Please do not email me personally.

                                _ Offline
                                _ Offline
                                _Flaviu
                                wrote on last edited by
                                #26

                                I only said that I updated the previous post.

                                1 Reply Last reply
                                0
                                • L Lost User

                                  I still cannot see enough information. Please provide what I previously requested and reply to this message. Please do not email me personally.

                                  _ Offline
                                  _ Offline
                                  _Flaviu
                                  wrote on last edited by
                                  #27

                                  I only said that I updated the previous post. Ok, I will come with new informations.

                                  1 Reply Last reply
                                  0
                                  • L Lost User

                                    I still cannot see enough information. Please provide what I previously requested and reply to this message. Please do not email me personally.

                                    _ Offline
                                    _ Offline
                                    _Flaviu
                                    wrote on last edited by
                                    #28

                                    The fact is like that: I have an error:

                                    error C2059: syntax error : '='

                                    the error is reported here:

                                    data->com = na->flags & ATTR_IS_COMPRESSED;

                                    where: data is a struct:

                                    struct data
                                    {
                                    .....
                                    int com;
                                    ...
                                    };

                                    and na is

                                    RECORD* na;

                                    and RECORD is:

                                    typedef struct {
                                    ....
                                    ....
                                    int flags;
                                    .....
                                    }RECORD;

                                    and

                                    ATTR_IS_COMPRESSED

                                    is from here (from my modifications):

                                    typedef int ATTR_FLAGS;

                                    //typedef enum {
                                    // ATTR_IS_COMPRESSED = 0x0001,
                                    // ATTR_COMPRESSION_MASK = 0x00ff,
                                    //}ATTR_FLAGS;

                                    #define ATTR_IS_COMPRESSED = 0x0001
                                    #define ATTR_COMPRESSION_MASK = 0x00ff

                                    L 1 Reply Last reply
                                    0
                                    • _ _Flaviu

                                      The fact is like that: I have an error:

                                      error C2059: syntax error : '='

                                      the error is reported here:

                                      data->com = na->flags & ATTR_IS_COMPRESSED;

                                      where: data is a struct:

                                      struct data
                                      {
                                      .....
                                      int com;
                                      ...
                                      };

                                      and na is

                                      RECORD* na;

                                      and RECORD is:

                                      typedef struct {
                                      ....
                                      ....
                                      int flags;
                                      .....
                                      }RECORD;

                                      and

                                      ATTR_IS_COMPRESSED

                                      is from here (from my modifications):

                                      typedef int ATTR_FLAGS;

                                      //typedef enum {
                                      // ATTR_IS_COMPRESSED = 0x0001,
                                      // ATTR_COMPRESSION_MASK = 0x00ff,
                                      //}ATTR_FLAGS;

                                      #define ATTR_IS_COMPRESSED = 0x0001
                                      #define ATTR_COMPRESSION_MASK = 0x00ff

                                      L Offline
                                      L Offline
                                      Lost User
                                      wrote on last edited by
                                      #29

                                      Not sure why you posted all that back to front ... However there are a couple of simple mistakes: #define statements do not require an = sign. They should be

                                      #define ATTR_IS_COMPRESSED 0x0001
                                      #define ATTR_COMPRESSION_MASK 0x00ff

                                      The name data refers to a struct definition, not a variable. You need something like:

                                      typedef struct
                                      {
                                      .....
                                      int com;
                                      ...
                                      } DATA;

                                      DATA* data;

                                      I am assuming that you actually assign the memory required for both structures at some point further on.

                                      _ 1 Reply Last reply
                                      0
                                      • L Lost User

                                        Not sure why you posted all that back to front ... However there are a couple of simple mistakes: #define statements do not require an = sign. They should be

                                        #define ATTR_IS_COMPRESSED 0x0001
                                        #define ATTR_COMPRESSION_MASK 0x00ff

                                        The name data refers to a struct definition, not a variable. You need something like:

                                        typedef struct
                                        {
                                        .....
                                        int com;
                                        ...
                                        } DATA;

                                        DATA* data;

                                        I am assuming that you actually assign the memory required for both structures at some point further on.

                                        _ Offline
                                        _ Offline
                                        _Flaviu
                                        wrote on last edited by
                                        #30

                                        That was the problem, on #define: I assigned with '='. My bad !

                                        1 Reply Last reply
                                        0
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes


                                        • Login

                                        • Don't have an account? Register

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • World
                                        • Users
                                        • Groups