warning: passing argument 1 makes pointer from integer without a cast

This is a discussion on warning: passing argument 1 makes pointer from integer without a cast within the C Programming forums, part of the General Programming Boards category; I get the above warning with the following code. I have used this same process in the past without any ...

  1. #1
    Registered User
    Join Date
    Aug 2008
    Location
    Delaware
    Posts
    32

    warning: passing argument 1 makes pointer from integer without a cast

    I get the above warning with the following code. I have used this same process in the past without any warning. I have not been able to eliminate the warning.

    Code:
    //FUNCTION
    
    int FUPW_f(int *index, int i)   //Pulse Width Function
    	{	
    		int j;
    		int FPW;
    		if (i > 3) j = 1;
    		else j = 0; 		
    		FPW = *(index + j);
    		return FPW;
    	}
    //main
    
    int FULPW[8];
    int FUPW_REG[2];
    int PWOFF;
    
    
    for (i = 0; i < 8; i++)		
    	{
    		FULPW[i] = (FUPW_f(*FUPW_REG, i) + PWOFF);	
    	}
    	}

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    FUPW_REG is an array of integers hence *FUPW_REG is the first integer in the array. FUPW_f's first parameter is a pointer to an integer, so what you should probably do is pass FUPW_REG instead of *FUPW_REG since the array would be converted to a pointer to its first element.

    By the way, a common convention is to reserve fully capitalised names for macro names.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Aug 2008
    Location
    Delaware
    Posts
    32
    laserlight,

    When I do that, I get:

    warning: passing argument 1 of 'FUPW_f' discards qualifiers from pointer target type

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Perhaps you're passing a const pointer to a function that expects a non-const pointer?
    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.

  5. #5
    Registered User
    Join Date
    Aug 2008
    Location
    Delaware
    Posts
    32
    Quote Originally Posted by dwks View Post
    Perhaps you're passing a const pointer to a function that expects a non-const pointer?
    OK, that's it. I was passing a volatile integer to a non-volatile pointer. It's working now. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The biggest project I've worked on: ASCIIpOrtal
    By guesst in forum Projects and Job Recruitment
    Replies: 19
    Last Post: 07-21-2009, 04:42 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 3
    Last Post: 01-14-2002, 11:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21