void example()
{
char x[80];
char (&refx)[] = x;
}
causes the following error messages
t.C: In function void example ():
t.C:4: `refx' undeclared (first use this function)
t.C:4: (Each undeclared identifier is reported only once
t.C:4: for each function it appears in.)
t.C:4: parse error before `]'
The whole area of references to arrays seems to have problems.
Lindsay
--
MAIL : Lindsay....@newcastle.ac.uk (UUCP: s/\(.*\)/...!ukc!\1/)
POST : Computing Laboratory, The University, Newcastle upon Tyne, UK NE1 7RU
VOICE: +44-91-222-8267 FAX: +44-91-222-8232
I came across this with function pointers. It seems as if g++ gets confused
when it sees the `(' after `char'.
Fix: put the keyword `auto' in front. eg, `auto char (&refx)[] = x;'
It worked for the function pointer problem and compiled (have tested
execution) for your example.
This only seems to be a problem with local variables. I've used
function pointers successfully as class members without `auto'.
-Daniel
Daniel Pezely <pez...@udel.edu> (NSFnet) 728 Bent Ln, Newark, DE 19711 | Skate
Comp Sci Lab, Smith Hall, U of Delaware, Newark, DE 19716; 302/451-6339 | ICE
The syntax supported by cfront for declaring pointers to functions or
pointers to arrays (or references to functions or references to arrays)
does not work in g++ in two contexts, i.e. local declarations, and
declarations of formal parameters.
In these cases, you must use a typedef or add the word 'auto'.
If you are dealing with formal parameters, you had better use a typedef
if you want your code to be portable to cfront.
// Ron Guilmette (r...@ics.uci.edu)
// C++ Entomologist
// Motto: If it sticks, force it. If it breaks, it needed replacing anyway.