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


Groups > comp.lang.c > #94015

Re: old c

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: old c
Date 2016-09-25 11:24 +0100
Organization A noiseless patient Spider
Message-ID <874m54ffaa.fsf@bsb.me.uk> (permalink)
References <qr5fub15dtp0k7pn5f8757638pfergcnhk@4ax.com>

Show all headers | View raw


Rosario19 <Ros@invalid.invalid> writes:

> i think
> in the compiler i use code as
>
> int v;g(u){v=strlen(u);}
> main(){return v==g("main");}
>
> would compile...

You may want to aim higher -- just managing to get some code to generate
an executable is a rather low bar, especially since C compilers tend to
be very generous in overlooking problems.

> in other compile compile too
>
> v;g(u){v=strlen(u);}
> main(){return v==g("main");}

Yes, that make the use of implicit int declarations consistent.  You
still have an extraneous newline, though.  Assuming a type of int when the
type is missing was always considered bad style (I'm going back to the
70s here) but it's not even legal syntax in modern C.

> but it not compile
> int v;g(u){return *u;}
> main(){return v==g("main");} 
>
> this because can not be done *u when u is one int

That's right.  Dereferencing an int is not permitted.  However, a
compiler is permitted to ignore that and generate code anyway.  I don't
know if any actually will.

> exist C compiler command option for programs that use int as a
> pointers to char?

Pass.  Why does it matter to you?

-- 
Ben.

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


Thread

old c Rosario19 <Ros@invalid.invalid> - 2016-09-25 11:41 +0200
  Re: old c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-25 11:24 +0100
    Re: old c Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-09-28 21:08 -0700
      Re: old c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-29 11:01 +0100
        Re: old c Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-29 10:11 -0400
          Re: old c Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-29 17:13 +0100
            Re: old c Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-09-29 09:51 -0700
            Re: old c Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-29 17:15 -0400
        Re: old c supercat@casperkitty.com - 2016-09-30 08:03 -0700
  Re: old c luser droog <luser.droog@gmail.com> - 2016-09-25 11:13 -0700
    Re: old c jgk@panix.com (Joe keane) - 2016-09-28 21:02 +0000
      Re: old c luser droog <luser.droog@gmail.com> - 2016-09-28 15:28 -0700

csiph-web