Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #61128

Re: Syntax error?

From Bartc <bc@freeuk.com>
Newsgroups comp.lang.c
Subject Re: Syntax error?
Date 2015-04-26 13:24 +0100
Organization A noiseless patient Spider
Message-ID <mhilbf$dfm$1@dont-email.me> (permalink)
References <mhg0mq$f25$1@dont-email.me> <mhiaif$7fj$1@news.albasani.net> <mhidu2$igd$1@dont-email.me>

Show all headers | View raw


On 26/04/2015 11:17, Bartc wrote:
> On 26/04/2015 10:19, Johannes Bauer wrote:
>> On 25.04.2015 14:19, Bartc wrote:
>>> How fast can you spot the problem in this code:
>>>
>>> *(int (*))((char*)sptr+8)=(*(int (*))((char*)x+8)/*(int
>>> (*))((char*)y+8));
>>
>> Since you already solved the mystery, I've got an unrelated question. Is
>> there a reason why the code generate puts the "*" in braces for "int
>> (*)"? I'm guessing there is, but I can't figure it out on the top of my
>> head.
>
> You mean, in parentheses?
>
> This is just my algorithm for converting an internal representation of
> the type into C type-spec syntax. It was easier to put the parentheses
> in everywhere than to try and figure out where they can be omitted.
>
> But I suppose I can suppress them in the simplest of cases such as the
> above.

Actually, even then I can't always leave them out:

     (int *[])p;

apparently doesn't mean the same as:

     (int (*)[])p;

The "()" around the "*" are added or suppressed before it knows this 
will be an array element type. So it's best to just leave them in.

Exactly why * is not the same as (*), I've no idea, and I don't want to 
know either; once this project is over I can forget about C type syntax 
for good I hope, because it is completely crazy.

(I don't think that (int *[]) is the equivalent of ((int *)[]) because 
that's a syntax error. Unless (int *) is the default but just not 
allowed to be specified in the syntax.)

-- 
Bartc





> (AFAIK this doesn't affect the resulting code in any way. But converting
> field selections to casts and offsets may be affecting code optimisation
> so I will try and tidy that up.)
>

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Syntax error? Bartc <bc@freeuk.com> - 2015-04-25 13:19 +0100
  Re: Syntax error? Richard Damon <Richard@Damon-Family.org> - 2015-04-25 11:07 -0400
  Re: Syntax error? jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-25 18:03 +0200
    Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-25 17:26 +0100
      Re: Syntax error? jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-25 19:28 +0200
  Re: Syntax error? Johannes Bauer <dfnsonfsduifb@gmx.de> - 2015-04-26 11:19 +0200
    Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-26 11:17 +0100
      Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-26 11:36 +0100
        Re: Syntax error? Ben Bacarisse <ben.lists@bsb.me.uk> - 2015-04-26 13:40 +0100
          Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-26 19:27 +0100
            Re: Syntax error? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-26 12:38 -0700
              Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-26 22:26 +0100
            Re: Syntax error? Keith Thompson <kst-u@mib.org> - 2015-04-26 12:41 -0700
            Re: Syntax error? Ben Bacarisse <ben.lists@bsb.me.uk> - 2015-04-27 01:53 +0100
      Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-26 13:24 +0100
  Re: Syntax error? Tim Rentsch <txr@alumni.caltech.edu> - 2015-04-26 07:01 -0700
    Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-26 19:55 +0100
      Re: Syntax error? Robert Wessel <robertwessel2@yahoo.com> - 2015-04-27 02:39 -0500
      Re: Syntax error? Tim Rentsch <txr@alumni.caltech.edu> - 2015-04-28 08:34 -0700

csiph-web