Re: [LIP] Function pointers not implemented on PPC ?
"Kapil Sethi" <mailkapil-cVJ5NjMFGLEMRHSAxyZ1NwC/[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Message-ID | <[email protected]> |
> On Tuesday 06 January 2004 16:31, Kapil Sethi wrote:
> > Hi,
> >
> > I have written a small code using pointers to function which compiles
and
> > runs on RHL 7.2 on P IV
> > However when I compile the same using gcc cross compiler for PPC the
> > program does not compile. Please help / suggest
> >
> > <code>
> > void test()
> > {
> > printf ("Hello Kapil\n");
> > }
> >
>
> Shouldn't that be void test(void) for standards sake?
I need to pass arguments to the called function, anyway gcc or
ppc-linux-gcc does not give any warnings for the same.
> > void main()
> > {
> > void (* myfunc)();
> > myfunc=&test;
>
> make that myfunc=test;
This is what is creating problem. both myfunc=test and myfunc=&test compiles
and executes as expected using gcc.
however ppc-linux-gcc gives error with myfunc=&test ->
<error>
invalid lvalue in unary '&'
</error>
while with myfunc=test compiles, but gives segmentation fault on running.
>
> HTH
>
> Shridhar
Kapil Sethi
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click