Re: forloop doesn't take define?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Robby" <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D31E6B50-8298-40F1-8EC0-6BF72CDB6999@xxxxxxxxxxxxxxxx
oaoaoaoh!
me double stupid!

Thankyou for your help fellows !

--
Best regards
Roberto


"Igor Tandetnik" wrote:

Robby <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
c:\_DTS_PROGRAMMING\C_PROGRAMMING\c\ARRAYSIZES\test.cpp(29): error
C2296: '/' : illegal, left operand has type 'long [5]'

#define SX (sizeof((obj_M->pCOLL[0].SFI) /
(sizeof(obj_M->pCOLL[0].SFI[0]))))

I'm pretty sure you wanted to arrange the parentheses differently. For
clarity, let's replace obj_M->pCOLL[0].SFI with A (for "array"):

#define SX (sizeof( (A) / (sizeof(A[0])) ))

So you try to do "A/sizeof(A[0])", and then apply sizeof to the result.
But of course A/sizeof(A[0]) is nonsense. You likely meant

#define SX ( sizeof(A) / sizeof(A[0]) )

See the difference?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925




This dialogue is a perfect example of how newsgroups should function, so
hats off to you both.

I would just add that as your example has demonstrated, macros and complex
things get muddled (in a Pooh sense), the following in a header file saves
my bacon (or honey) time and again.

//

// A means of finding the size of a fixed array which also has the nice

// property that it fails if passed a pointer, unlike
(sizeof(pointer)/(pointer[0])).

//

//
http://groups-beta.google.com/group/microsoft.public.vc.ide_general/msg/cb86476c29a61072?dmode=source

//

template <typename Type, ::size_t nElements> inline

::size_t sizeof_array(const Type (&)[nElements])

{

return nElements;

}


.



Relevant Pages

  • Re: forloop doesnt take define?
    ... me double stupid! ... Best regards ... "Igor Tandetnik" wrote: ... But of course A/sizeofis nonsense. ...
    (microsoft.public.vc.language)
  • Re: csh to bash
    ... never seen one that didn't have a bunch defined right out of the ... Me too, stupid 'rm -i' nonsense, then the next thing I do is 'alias h=history' ...
    (comp.unix.shell)
  • Re: [Full-disclosure] NorfolkDesign.com proven track of excellence
    ... Scripting and made several terribly stupid points in addition to your ... Ronnie - Norfolk Design to me: ... jumbo some cheap lawyer scribbled on the back of an envelope in the bar ... increasing nonsense, go spend a few quid on a _competent_ IT lawyer and ...
    (Full-Disclosure)
  • Re: Clarification of My Proof That Einsteins RoS is Pure Nonsense.
    ... |> Thanks for confirming that you don't see the difference ... to know sense from nonsense. ... are so thoroughly stupid as to not know parentheses take ... that he doesn't admit a blunder even when he has his face shoved into it. ...
    (sci.physics.relativity)
  • Re: What reliance on a homeopaths advice can cause
    ... Because it is not recognized by modern science. ... Every Time I see that bit of nonsense [I wonder where she picked it ... Its amazing what they see fit to denounce as stupid and crazy ...never looking in their own nests, ... The allopaths need to take a good hard look at their own ideologies and see how stuffed they are. ...
    (misc.health.alternative)