• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: invalid operands to binary?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: invalid operands to binary?


  • Subject: Re: invalid operands to binary?
  • From: Shawn Erickson <email@hidden>
  • Date: Fri, 14 May 2004 11:30:42 -0700

On May 14, 2004, at 10:29 AM, Shawn Erickson wrote:

On May 14, 2004, at 9:50 AM, email@hidden wrote:

why does this:
unsigned long long *total;
unsigned long long totalFileSizeK = total/1024;

give me this:
invalid operands to binary /

is there something easy i'm missing here?

In the above total is defined as a pointer to a ulonglong (the *) and when you do "total/1024" you are attempting to divide the value of the pointer (not the ulonglong). Surprised it is giving you this error/warning [1] but... try "(*total)/1024" which dereferences total to get at the ulonglong. Of course total needs to point at an allocated ulonglong which in the above it doesn't appear to be.

I assume you are using a function that wants a pointer to a ulonglong and that is why you have defined total as you have, so...

unsigned long long total, totalFileSizeK;
someFuntionThatWantsAPointerToTotal( &total );
totalFileSizeK = total / 1024;

& = pointer (reference) to variable, address of the variables storage basically
* = deference a pointer, data from the memory addressed basically

-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >invalid operands to binary? (From: email@hidden)
 >Re: invalid operands to binary? (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Window Styles
  • Next by Date: NSTableView customization
  • Previous by thread: Re: invalid operands to binary?
  • Next by thread: Re: invalid operands to binary?
  • Index(es):
    • Date
    • Thread