Argument type 'void' is incomplete

Discussion in 'iPhone/iPad Programming' started by markdaraju, Sep 20, 2012.

  1. markdaraju, Sep 20, 2012
    Last edited by a moderator: Sep 20, 2012

    macrumors newbie

    Joined:
    Sep 20, 2012
    #1
    Hi all,

    I have just been asked to take ownership of iOS code of one of our company's apps.
    It was quite a struggle to get the code to build on my machine (OSX 10.8, Xcode4.5 and simulator 5.1/6.0) but now most of the errors have been resolved except for this one that says "Argument type 'void' is incomplete"

    The line that it's pointing at is

    Code:
    "
    	for(int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++){
    ---------->>       [COLOR="Red"] [output appendFormat:@"%02x", macOut.mutableBytes[i]];[/COLOR]
        }
    "
    Apparently , there is something wrong with variable macOut. Following is the declaration of macOut :

    Code:
    "	NSMutableData *macOut = [NSMutableData  dataWithLength:CC_SHA256_DIGEST_LENGTH];
    
    	CC_SHA256(dataIn.bytes, dataIn.length,  macOut.mutableBytes);
    
    	NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH * 2];
    "
    I can't see anything missing but again, I am not very experienced in iOS programming. Appreciate if you can provide any pointers on resolving this .

    Thanks,
    Mark
     

    Attached Files:

  2. ArtOfWarfare, Sep 20, 2012
    Last edited: Sep 20, 2012

    macrumors 603

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    Two declarations I'd like to see the code for:

    1 - appendFormat:
    2 - mutableBytes[]

    Oh, and have you tried dereferencing mutableBytes? Maybe *macOut.mutableBytes will work better...? mutableBytes[] could just be an array of pointers pointing to the actual values, thus they'd need dereferencing to be used, right? I'm not quite sure why you'd get the error that you're getting, though...

    Edit: Nevermind. mutableBytes is a standard NSMutableData ivar...

    2X Edit: mutableBytes is a void*. Dereferencing it (by using ) will give you a void. So shouldn't you cast it to an int before you try printing it?
     
  3. macrumors 603

    Joined:
    Aug 9, 2009
    #3


    I'm pretty sure the goal of the posted code is to step through the bytes of the NSMutableData (note how i steps), formatting each byte as hex (%02x) as it's appended to a string (appendFormat:).

    Unfortunately, the returned type is void*, not uint8_t* (see the standard C header stdint.h). Which should suggest a solution if one knows basic C. It's not even specific to iOS programming or Objective-C, just basic C skills.
     
  4. thread starter macrumors newbie

    Joined:
    Sep 20, 2012
    #4
    The confusing part is this apparently compiled fine in 10.7 + Xcode 4.3 that the previos developers had used. They are no longer available for comments hence the conundrum. In the meantime I have tried a few different approaches such as type casting and using temp variables etc. but none of that seem to be helping.


    Any other ideas ? I understand that I might be making very basic mistakes here but I do intend to learn as much as I can in the process.

    Thanks for your responses!
     

    Attached Files:

  5. macrumors 603

    Joined:
    Aug 9, 2009
    #5
    Honestly, I find that hard to believe. When I look up that method in older reference docs, it has always returned (void*). And ever since the 'void' type was created, it's been illegal to dereference a pointer to that type. So unless there was a compiler bug that somehow allowed it, or the declared return-type somehow changed for a brief period, I see no way it could ever work as given.


    When posting code, it's better to copy and paste actual text. It's much easier to work with than pictures of text.

    As given in the picture, your type-cast is completely wrong. You need to cast the pointer before it's subscripted. You also need to cast it to the correct type, an unsigned byte, otherwise you won't be converting the bytes of the data, you'll be converting the bytes-interpreted-as-ints. A suitable temp variable of the correct type would also work:
    Code:
    uint8_t * theBytes = [macOut mutableBytes];
    for(int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++){
       [output appendFormat:@"%02x", theBytes[i]];
    }
    
    As I said before, it's basic C.
     

Share This Page