Thread: Pointer Conversion

  1. #1
    Registered User
    Join Date
    Jan 2017
    Posts
    4

    Pointer Conversion

    I know that i'm doing something wrong but this is the third time that I post this, for some reason after posting I cannot find the message in the board, sorry if I repeated this for the third time.

    I'm working with the EEPROM from an AVR chip using the avr eeprom library. I'm using the following function:
    Code:
     void eeprom_read_block (void *pointer_ram, const void *pointer_eeprom, size_t n)
    Here is a sample of the program:
    main.c
    Code:
    #include <avr/eeprom.h>
    
    typedef myStruct {
    int parA; float parB;
    } void main(){
    myStruct theStruct; readData(&theStruct);
    } void readData(myStruct *tempStruct){
    eeprom_read_block((void *)temStruct->parA, (void *)0, sizeof(temStruct->parA)); eeprom_read_block((void *)temStruct->parB, (void *)10, sizeof(temStruct->parB);
    }
    The problem is that I'm getting a "cannot convert to a pointer type" error message at the line where is a float, parB in this case. Does anyone knows the solution to this problem?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Perhaps you need to pass the address of the float instead, e.g.,
    Code:
    eeprom_read_block(&temStruct->parB, (void *)10, sizeof(temStruct->parB);
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2017
    Posts
    4
    You are complete correct, I had forgotten to add the &. Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Nonportable pointer conversion - please help
    By amir1986 in forum C Programming
    Replies: 2
    Last Post: 01-20-2011, 04:21 AM
  2. Why does C need pointer conversion
    By password636 in forum C Programming
    Replies: 2
    Last Post: 04-10-2009, 07:33 AM
  3. help me in conversion using pointer
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 08-20-2002, 12:15 AM

Tags for this Thread