Thread: Nonportable pointer conversion - please help

  1. #1
    Registered User
    Join Date
    Jan 2011

    Question Nonportable pointer conversion - please help

    I have this struct
    typedef struct _Vector_t* Vector;
    typedef void *Elem;
    struct _Vector_t {
    Elem *array;
    int intOrChar;
    int arraysize;
    int numOfElements;
    Lets say the there are some elements in the array . lets say (1,2,3,4)
    I want to reverse them in the array using a recursion
    I wrote this function :

    Result Reverse_Vector(Vector v,int length)
    {   int tempVal;
    		if(length <= (v->arraysize)/2)
    			return Success;
    		tempVal = v->array[length-1]; // Nonportable pointer conversion		
                                    v->array[length- 1]= v-array[v->arraysize - length]; //undifined symbol "array"
    		v->array[(v->arraysize) - length] = tempVal; //Nonportable pointer conversion
    		return Reverse_Vector(v,length -1);
    can anyone help me I just don't know what is the problem here ..

  2. #2
    Registered User
    Join Date
    Jun 2005
    Declare tempVal to be of type Elem, not an int. That will eliminate the complaints about a non-portable pointer conversion. The reason is that, if you want to store an element of an array in a variable, that variable needs to be the same type (or a type compatible with) the elements of the array.

    The undefined symbol array message is probably resulting from a typo: leaving a '>' out of "v->array[etc etc]". Confusing a compiler with a typo is an effective way of getting confusing error messages.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    Jan 2011
    Thanx man it worked..GOD i forgot that it's a type of an Elem .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what does this pointer type conversion do?
    By casmac in forum C Programming
    Replies: 4
    Last Post: 06-02-2010, 11:04 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Pointer array's and ASCII to bit conversion
    By AdamLAN in forum C++ Programming
    Replies: 12
    Last Post: 05-06-2005, 05:55 PM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. Replies: 2
    Last Post: 02-07-2002, 09:39 AM

Tags for this Thread