A
Andreas Leitner
Hi,
I got a code snipset that gcc refuses to compile. I am note sure however
whether this is a bug in gcc, or the snipset is just invalid C code.
This is the source code in question:
----
typedef int foo;
void bar1 (foo* foo)
{
}
void bar2 (foo foo)
{
bar1((foo*) foo);
}
int main (void)
{
}
---
And this is what gcc 3.3.4 tells me about it:
---
foo.c: In function `bar2':
foo.c:9: error: parse error before ')' token
---
If I remove the cast, gcc compiles the sample just fine. 'foo' is
overloaded to be a type name and parameter in both funciton 'bar1' and
'bar2'. Such overloading seems to be legal ('bar1' alone and 'bar2'
without the cast compile just fine). However the cast doesnt seem to
work. This restriction seems a bit arbitrary to me, is the cast legal C
or not?
I do know that the name overloading is bad style. I extracted the
snipset from generated code.
many thanks in advance,
Andreas
I got a code snipset that gcc refuses to compile. I am note sure however
whether this is a bug in gcc, or the snipset is just invalid C code.
This is the source code in question:
----
typedef int foo;
void bar1 (foo* foo)
{
}
void bar2 (foo foo)
{
bar1((foo*) foo);
}
int main (void)
{
}
---
And this is what gcc 3.3.4 tells me about it:
---
foo.c: In function `bar2':
foo.c:9: error: parse error before ')' token
---
If I remove the cast, gcc compiles the sample just fine. 'foo' is
overloaded to be a type name and parameter in both funciton 'bar1' and
'bar2'. Such overloading seems to be legal ('bar1' alone and 'bar2'
without the cast compile just fine). However the cast doesnt seem to
work. This restriction seems a bit arbitrary to me, is the cast legal C
or not?
I do know that the name overloading is bad style. I extracted the
snipset from generated code.
many thanks in advance,
Andreas