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. Annoying Compiler Warning

Annoying Compiler Warning

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structuresbusinesshelptutorial
4 Posts 2 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.
  • S Offline
    S Offline
    Steve Thresher
    wrote on last edited by
    #1

    I have the following code in my program (written in C not C++):

    typedef struct
    {
    char *(*errors)[];
    }ERROR_LIST;

    char *errors[]=
    {
    "An error",
    "Another error",
    };

    ERROR_LIST err_list={&errors}; // <--- Error on this line

    The declaration gives the following compiler error on the line indicated. warning C4048: different array subscripts : 'char *(*)[]' and 'char *(*__w64 )[2]' I am using the /w64 compiler switch intentionally to maintain 64bit compatibility. Could somebody please give me a clue how to resolve this warning as its driving me nuts! Systems AXIS Ltd - Software for Business ...

    P 1 Reply Last reply
    0
    • S Steve Thresher

      I have the following code in my program (written in C not C++):

      typedef struct
      {
      char *(*errors)[];
      }ERROR_LIST;

      char *errors[]=
      {
      "An error",
      "Another error",
      };

      ERROR_LIST err_list={&errors}; // <--- Error on this line

      The declaration gives the following compiler error on the line indicated. warning C4048: different array subscripts : 'char *(*)[]' and 'char *(*__w64 )[2]' I am using the /w64 compiler switch intentionally to maintain 64bit compatibility. Could somebody please give me a clue how to resolve this warning as its driving me nuts! Systems AXIS Ltd - Software for Business ...

      P Offline
      P Offline
      pepe 0
      wrote on last edited by
      #2

      And like this ? : typedef struct { char *(*errors)[]; } ERROR_LIST; char *errors[]; ERROR_LIST err_list={&errors}; char *errors[]={"An error","Another error",};

      S 1 Reply Last reply
      0
      • P pepe 0

        And like this ? : typedef struct { char *(*errors)[]; } ERROR_LIST; char *errors[]; ERROR_LIST err_list={&errors}; char *errors[]={"An error","Another error",};

        S Offline
        S Offline
        Steve Thresher
        wrote on last edited by
        #3

        That works but can you explain why? Systems AXIS Ltd - Software for Business ...

        P 1 Reply Last reply
        0
        • S Steve Thresher

          That works but can you explain why? Systems AXIS Ltd - Software for Business ...

          P Offline
          P Offline
          pepe 0
          wrote on last edited by
          #4

          I'm not a guru but I suppose the the compiler interpret (well a compiler does'nt interpret code, but...) : char *str[] = {"one", "two"}; as char *str[2] = {"one", "two"}; I think (not shure) that your code might compile in old C but not in C++ (new behaviour).

          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