Thread: pointer from integer without a cast - warning

  1. #16
    Registered User
    Join Date
    Jan 2012
    Location
    Galati, Romania
    Posts
    9
    @anduril462: here is an example of key-value pair:

    /* rotation of the image in degrees (0 to 359) */
    ROTATION = 1

    /* possible formats */ FORMAT = HAL_PIXEL_FORMAT_RGB_565

  2. #17
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Okay, so like I said, you either need two different functions, one to return the string value and one to return the int value, and call the right one based on whether you're looking up "ROTATION" or "FORMAT", or you only have a get_str_val function that returns the string version of the value, and if the key was "ROTATION", you convert the string to a number using strtol.

    Code:
    int rotation_value;
    char *format_value;
    if key is "ROTATION"
        rotation_value = get_int_val(key);
    else if key is "FORMAT"
        format_value = get_str_val(key);
    or
    Code:
    char *str_value;
    int rotation_value;
    char *format_value;
    str_value = get_str_val(key);
    if key is "ROTATION"
        rotation_value = strtol(key, ...);
    else if key is "FORMAT"
        format_value = str_value;

  3. #18
    Registered User
    Join Date
    Jan 2012
    Location
    Galati, Romania
    Posts
    9
    Thank you so much for your suggestions. I will try it out and let you know tomorrow.

    Thank you all for the answers!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 02-12-2011, 07:33 PM
  2. Replies: 4
    Last Post: 03-03-2010, 01:06 PM
  3. Replies: 4
    Last Post: 03-10-2009, 10:29 AM
  4. Replies: 1
    Last Post: 12-23-2008, 09:39 AM
  5. warning: cast to pointer from integer of different size
    By DavidDobson in forum C Programming
    Replies: 6
    Last Post: 12-03-2008, 06:37 PM

Tags for this Thread