Nonportable pointer conversion - please help

This is a discussion on Nonportable pointer conversion - please help within the C Programming forums, part of the General Programming Boards category; I have this struct Code: typedef struct _Vector_t* Vector; typedef void *Elem; struct _Vector_t { Elem *array; int intOrChar; int ...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    5

    Question Nonportable pointer conversion - please help

    I have this struct
    Code:
    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 :

    Code:
    Result Reverse_Vector(Vector v,int length)
    {   int tempVal;
    		if(length <= (v->arraysize)/2)
    			return Success;
    		else
    		{
    		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
    Posts
    6,529
    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 in reply to you, it is likely you deserve it. Suck it up, sunshine, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    5
    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, 12:04 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  3. Pointer array's and ASCII to bit conversion
    By AdamLAN in forum C++ Programming
    Replies: 12
    Last Post: 05-06-2005, 06:55 PM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 08:48 PM
  5. Replies: 2
    Last Post: 02-07-2002, 09:39 AM

Tags for this Thread


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