This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Request for suggestions: xm-romp.h
On Fri, Mar 16, 2001 at 05:08:49PM -0800, Richard Henderson wrote:
> On Fri, Mar 16, 2001 at 02:04:07PM -0800, Zack Weinberg wrote:
> > #define GEN_FCN(CODE) (insn_data[(int) (CODE)].genfun)
> > #else
> > #define GEN_FCN(CODE) (*insn_data[(int) (CODE)].genfun)
>
> The former is also acceptable to ISO C. Does it cause K&R problems?
My understanding is that the former does cause K+R problems, but I
have no proof.
README.Portability is confused:
#K+R C compilers require parentheses around the dereferenced function
#pointer expression in the call, whereas ISO C relaxes the syntax. For
#example
#
#typedef void (* cl_directive_handler) PARAMS ((cpp_reader *, const char *));
# *p->handler (pfile, p->arg);
#
#needs to become
#
# (*p->handler) (pfile, p->arg);
The parentheses are always necessary if you're using *funcptr,
otherwise it means to dereference the return value of the function.
What ISO C says is that you can write
p->handler (pfile, p->arg);
As I understand it, this was a common but not ubiquitous extension in
K+R days.
Anyone know more accurately than me?
zw