Thread: warning C4047: '=' : 'int' differs in levels of indirection from 'int *__w64

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    93

    warning C4047: '=' : 'int' differs in levels of indirection from 'int *__w64

    I do not understand what this error message means.

    What is wrong with this code?

    Code:
    int cio_edit(char *str, int row, int col, int flen, int slen,
                    int *ins, int *curpos, int *spos, int isMultiLine)
    {
        int ch, 
            insert = 1,
            cursorP = 0,
            offsetP = 0;
    
      
            if(*ins==NULL){*ins = &insert;}
           if(*curpos==NULL){*curpos = &cursorP;}
           if(*spos==NULL){*spos = &offsetP;} 
    
    }

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    variable ins is a pointer. *ins is an integer. the code should be like this
    Code:
    if( ins == NULL)   ins = &insert;

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    variable ins is a pointer. *ins is an integer. the code should be like this
    No it shouldn't. If he does it that way, then the value that ins points to goes out of scope once the function ends.

    It should be:
    Code:
    if( ins == NULL)   *ins = insert;
    And the same goes for the two other assignments in that function.

  4. #4
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Quote Originally Posted by bithub
    No it shouldn't. If he does it that way, then the value that ins points to goes out of scope once the function ends.

    It should be:
    Code:
    if( ins == NULL)   *ins = insert;
    And the same goes for the two other assignments in that function.
    Your code dereferences a null pointer.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Maybe bithub meant
    Code:
    if(ins != NULL) *ins = insert;
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need some help...
    By darkconvoy in forum C Programming
    Replies: 32
    Last Post: 04-29-2008, 03:33 PM
  2. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  3. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  4. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 12:36 PM
  5. Try out my new game :) !
    By Stan100 in forum Game Programming
    Replies: 10
    Last Post: 06-05-2003, 08:10 AM