Group: comp.lang.c++
From: James Kanze
Date: Saturday, February 16, 2008 3:14 PM
Subject: Re: Initializing a temporary with the return value of a function call

On Feb 16, 2:23 pm, Ron Natalie wrote:
> Marcel M=FCller wrote:

> > void foo()
> > { MenuShowAccel(WinQueryAccelTable(hab, hframe)).ApplyTo(hmenu);
> > }
> > ----------

> You're running afoul of the C++ rule that if it possibly could be
> a declaration, to consider it such.

I think for the above to be a function, hab and hframe would
have to be the names of types, which they aren't. Also,
although I'm not sure, I think that there is enough context to
disambiguate---a function declaration cannot be followed by a
point (but I'm not sure whether look-ahead has to be considered,
and if so, how much).

FWIW: his code compiles for me (g++ 4.2.1 under Linux). His
error messages also seem to suggest that his compiler is also
treating MenuShowAccel as a function in the line in question.
In fact, it looks like the compiler is treating
WinQueryAccelTable as a macro which expands to its arguments
here, but if that were the case, the previous declaration would
not compile.

> It thinks you're defining a function called WinQueryAccelTable
> that returns a MenuShowAccel.

I don't think so. It shouldn't, and that doesn't correspond to
the error messages he posted either.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34