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


Groups > comp.lang.c > #4520 > unrolled thread

Types in C

Started byjacob navia <jacob@spamsink.net>
First post2011-05-22 21:29 +0200
Last post2011-06-02 15:26 -0700
Articles 20 on this page of 123 — 20 participants

Back to article view | Back to comp.lang.c


Contents

  Types in C jacob navia <jacob@spamsink.net> - 2011-05-22 21:29 +0200
    Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-22 12:48 -0700
    Re: Types in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-22 23:03 +0100
      Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-23 10:35 +0200
        Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-23 08:40 -0700
          Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-23 17:19 +0000
            Re: Types in C John Gordon <gordon@panix.com> - 2011-05-23 17:54 +0000
              Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-23 11:33 -0700
                Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-23 11:44 -0700
              Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-23 19:08 +0000
            Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-23 20:50 +0200
              Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-23 12:11 -0700
                Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-23 19:45 +0000
                  Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-23 13:03 -0700
                    Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-23 22:25 +0200
                      Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-23 14:38 -0700
                        Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-23 23:45 +0200
                        Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-23 22:02 +0000
                          Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-24 00:10 +0200
                  Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-23 22:12 +0200
                    Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-23 13:27 -0700
                      Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-23 22:33 +0200
                        Re: Types in C Martin Ambuhl <mambuhl@earthlink.net> - 2011-05-24 03:17 -0400
                          Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-24 10:55 +0200
                    Re: Types in C Ian Collins <ian-news@hotmail.com> - 2011-05-24 09:29 +1200
                      Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-23 23:42 +0200
                        Re: Types in C Ian Collins <ian-news@hotmail.com> - 2011-05-24 09:51 +1200
                          Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-24 00:04 +0200
                            Re: Types in C Ian Collins <ian-news@hotmail.com> - 2011-05-24 10:57 +1200
                            Re: Types in C David Thompson <dave.thompson2@verizon.net> - 2011-06-01 16:33 -0400
                    Re: Types in C Shao Miller <sha0.miller@gmail.com> - 2011-05-23 19:33 -0500
                    Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-24 08:27 -0700
                    Re: Types in C Tim Rentsch <txr@alumni.caltech.edu> - 2011-05-31 00:40 -0700
                      Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-31 11:32 +0200
                        Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-31 11:30 -0700
                        Re: Types in C Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-01 01:23 -0700
                  Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-23 16:51 -0400
                    Re: Types in C Ian Collins <ian-news@hotmail.com> - 2011-05-24 09:25 +1200
                      Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-23 23:40 +0200
                        Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-24 08:36 -0700
                      Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-23 17:53 -0400
                        Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-23 22:24 +0000
                          Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-23 19:23 -0400
                            Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-23 23:57 +0000
                              Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-23 21:22 -0400
                                Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-24 03:46 +0000
                                  Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-24 00:24 -0400
                                    Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-24 04:44 +0000
                                    Re: Types in C pete <pfiland@mindspring.com> - 2011-05-24 07:46 -0400
                                Re: Types in C James Kuyper <jameskuyper@verizon.net> - 2011-05-24 07:48 -0400
                        Re: Types in C Ian Collins <ian-news@hotmail.com> - 2011-05-24 10:35 +1200
                          Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-23 22:38 +0000
                            Re: Types in C Ian Collins <ian-news@hotmail.com> - 2011-05-24 10:53 +1200
                              Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-23 23:17 +0000
                                Re: Types in C Ian Collins <ian-news@hotmail.com> - 2011-05-24 11:24 +1200
                                  Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-23 23:39 +0000
                                    Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-24 11:23 +0200
                                      Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-24 08:46 -0700
                                        Re: Types in C Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-05-24 09:14 -0700
                            Re: Types in C Michael Press <rubrum@pacbell.net> - 2011-05-28 21:50 -0700
                              Re: Types in C "io_x" <a@b.c.invalid> - 2011-06-07 19:50 +0200
                          Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-23 19:33 -0400
                            Re: Types in C Ian Collins <ian-news@hotmail.com> - 2011-05-24 12:03 +1200
                              Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-23 21:27 -0400
                                Re: Types in C Ian Collins <ian-news@hotmail.com> - 2011-05-24 13:47 +1200
                                  Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-23 23:45 -0400
                                  Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-24 00:07 -0700
                            Re: Types in C James Kuyper <jameskuyper@verizon.net> - 2011-05-24 08:05 -0400
                        Re: Types in C Shao Miller <sha0.miller@gmail.com> - 2011-05-23 19:54 -0500
                          Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-23 21:03 -0400
                            Re: Types in C Shao Miller <sha0.miller@gmail.com> - 2011-05-23 22:12 -0500
                              Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-24 00:03 -0400
                                Re: Types in C pete <pfiland@mindspring.com> - 2011-05-24 00:19 -0400
                                  Re: Types in C pete <pfiland@mindspring.com> - 2011-05-24 00:20 -0400
                                Re: Types in C Shao Miller <sha0.miller@gmail.com> - 2011-05-24 00:46 -0500
                                  Re: Types in C pete <pfiland@mindspring.com> - 2011-05-24 07:36 -0400
                                  Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-24 10:58 -0400
                                    Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-24 09:40 -0700
                                      Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-24 21:36 -0400
                                      Re: Types in C David Thompson <dave.thompson2@verizon.net> - 2011-06-01 16:33 -0400
                                    Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-24 16:50 +0000
                                      Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-24 21:10 -0400
                                        Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-24 18:19 -0700
                                          Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-24 21:42 -0400
                                            Re: Types in C Shao Miller <sha0.miller@gmail.com> - 2011-05-24 23:47 -0500
                                              Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-25 10:13 -0400
                                        Re: Types in C Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-05-24 22:19 -0600
                                      Re: Types in C Dr Nick <3-nospam@temporary-address.org.uk> - 2011-05-25 07:04 +0100
                                        Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-25 08:53 -0700
                                          Re: Types in C Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-05-25 10:11 -0600
                                  Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-24 09:02 -0700
                        Re: Types in C James Kuyper <jameskuyper@verizon.net> - 2011-05-24 07:37 -0400
                    Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-23 22:02 +0000
                      Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-23 18:15 -0400
                        Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-23 22:25 +0000
                          Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-23 19:39 -0400
                            Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-23 23:57 +0000
                              Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-23 21:10 -0400
                                Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-24 01:58 +0000
                                  Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-23 23:56 -0400
                                    Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-24 04:32 +0000
                                      Re: Types in C "BartC" <bc@freeuk.com> - 2011-05-25 01:29 +0100
                                Re: Types in C Shao Miller <sha0.miller@gmail.com> - 2011-05-23 22:20 -0500
                                  Re: Types in C Shao Miller <sha0.miller@gmail.com> - 2011-05-23 22:42 -0500
                                  Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-24 00:07 -0400
                                    Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-24 04:44 +0000
                                      Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-24 10:24 -0400
                                        Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-24 16:50 +0000
                                          Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-24 21:16 -0400
                                            Re: Types in C Seebs <usenet-nospam@seebs.net> - 2011-05-25 03:36 +0000
                                    Re: Types in C Shao Miller <sha0.miller@gmail.com> - 2011-05-24 01:26 -0500
                                      Re: Types in C Uncle Steve <stevet810@gmail.com> - 2011-05-24 11:04 -0400
                              Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-24 09:06 -0700
              Re: Types in C David Thompson <dave.thompson2@verizon.net> - 2011-06-01 16:33 -0400
    Re: Types in C Marcin Grzegorczyk <mgrzegor@poczta.onet.pl> - 2011-05-30 22:42 +0200
      Re: Types in C Shao Miller <sha0.miller@gmail.com> - 2011-05-30 17:45 -0500
        Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-05-31 08:47 -0700
          Re: Types in C Shao Miller <sha0.miller@gmail.com> - 2011-05-31 13:54 -0400
      Re: Types in C jacob navia <jacob@spamsink.net> - 2011-05-31 00:16 +0200
        Re: Types in C Shao Miller <sha0.miller@gmail.com> - 2011-05-30 18:30 -0500
        Re: Types in C Marcin Grzegorczyk <mgrzegor@poczta.onet.pl> - 2011-06-02 22:44 +0200
          Re: Types in C jacob navia <jacob@spamsink.net> - 2011-06-02 22:49 +0200
            Re: Types in C Keith Thompson <kst-u@mib.org> - 2011-06-02 15:26 -0700

Page 3 of 7 — ← Prev page 1 2 [3] 4 5 6 7  Next page →


#4606

FromUncle Steve <stevet810@gmail.com>
Date2011-05-23 17:53 -0400
Message-ID<50d915539d62563-19304@gmail.com>
In reply to#4597
On Tue, May 24, 2011 at 09:25:29AM +1200, Ian Collins wrote:
> On 05/24/11 08:51 AM, Uncle Steve wrote:
> >On Mon, May 23, 2011 at 07:45:24PM +0000, Seebs wrote:
> >>On 2011-05-23, Keith Thompson<kst-u@mib.org>  wrote:
> >>>Just a quibble: size_t may be exactly the same type as unsigned long,
> >>>since a typedef merely creates an alias for an existing type, not
> >>>a new and distinct type.  plain char and signed char (for example)
> >>>are distinct in a way that size_t and unsigned long (for example)
> >>>are not.
> >>
> >>True.  Although, possibly confusingly, there are places where it seems
> >>that the thing a typedef creates is itself then called "a type".  The
> >>wording is a bit fuzzy.
> >>
> >>We all know what we mean, I think.  You could say it several ways:
> >>
> >>	Typedef does not actually create types; instead, it creates
> >>	names which refer to existing types.
> >>
> >>	Typedef creates types, but those types are identical to existing
> >>	types and can be used interchangably with them.
> >
> >How about the idea that typedefs create aliases for the basic built-in
> >types supplied by the language spec.?
> 
> A typedef may provide an alias to any existing type, built-in, user 
> defined or even incomplete.

There are no "user defined" types in C.  Structures and unions are
aggregates of basic types (and structures/unions).  I believe
incomplete types are a (usually temporary) artifact of the compilation
process and you won't ever see them in a running program.

Correct me if I'm wrong, but I've never heard of a C compiler that
allows you to define something like a BCD integer type when the
compiler has no built-in support for it.  This is reasonable since the
compiler can only generate arithmetic code for types it 'understands'.
If you invent your own arithmetic type (as they do in the gmp
library) the compiler 'sees' it as opaque binary data, and arithmetic
operations are carried out with ... macros and function calls.

BTW, have a look at the gmp.h header and note that they do not shy
away from macro-like functions.  Not that I care a whole lot, but I'd
say the writers of the gmp library probably know more than you do
about the suitability of inline functions versus macros and when to
use each.  Just a 'feeling' on the matter, which is not to say that
you're entirely wrong.



Regards,

Uncle Steve

-- 
Should a professional politician be charged with molestation if he
kisses babies while attending political rallies?

[toc] | [prev] | [next] | [standalone]


#4614

FromSeebs <usenet-nospam@seebs.net>
Date2011-05-23 22:24 +0000
Message-ID<slrnitlmem.13do.usenet-nospam@guild.seebs.net>
In reply to#4606
On 2011-05-23, Uncle Steve <stevet810@gmail.com> wrote:
> There are no "user defined" types in C.

Sure there are!

> Structures and unions are
> aggregates of basic types (and structures/unions).

Sure.

So?  Doesn't make them not types.  Pointers, arrays, enums, structs,
unions... all types.  Structs and unions are user-defined.  And they are
types.  This makes them... *drumroll* user-defined types.

> BTW, have a look at the gmp.h header and note that they do not shy
> away from macro-like functions.  Not that I care a whole lot, but I'd
> say the writers of the gmp library probably know more than you do
> about the suitability of inline functions versus macros and when to
> use each.  Just a 'feeling' on the matter, which is not to say that
> you're entirely wrong.

I would guess that one of the times to use macros is "when you have to
be portable to compilers that don't have inline functions".  That's
definitely a key application.

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

[toc] | [prev] | [next] | [standalone]


#4626

FromUncle Steve <stevet810@gmail.com>
Date2011-05-23 19:23 -0400
Message-ID<aa0d3dd810992cb-f68f6@gmail.com>
In reply to#4614
On Mon, May 23, 2011 at 10:24:31PM +0000, Seebs wrote:
> On 2011-05-23, Uncle Steve <stevet810@gmail.com> wrote:
> > There are no "user defined" types in C.
> 
> Sure there are!

Oh, no there aren't!
 
> > Structures and unions are
> > aggregates of basic types (and structures/unions).
> 
> Sure.
> 
> So?  Doesn't make them not types.  Pointers, arrays, enums, structs,
> unions... all types.  Structs and unions are user-defined.  And they are
> types.  This makes them... *drumroll* user-defined types.

Not if we make a finer distinction between types.  As I see it there
are two types of types:

char, int, long, float, void *, etc. are /basic types/ fundamental to
the implementation of the C language (and arithmetic operations).
Compound types are aggregates of these basic types as well as compound
types.  There's a fundamental difference you are ignoring given a
sufficient vague definition of 'type'.

A real user-defined type would be something new like the complex
numbers extension in gcc.  I don't do much OOP, but someone here
probably knows of a language that allows new fundamental type
definitions without direct compiler support.  C requires compiler
support for this.  So, if you want a 128-byte integer type either you
modify the compiler to emulate arithmetic operations with smaller asm
instructions, or you write a library to handle it.
 
> > BTW, have a look at the gmp.h header and note that they do not shy
> > away from macro-like functions.  Not that I care a whole lot, but I'd
> > say the writers of the gmp library probably know more than you do
> > about the suitability of inline functions versus macros and when to
> > use each.  Just a 'feeling' on the matter, which is not to say that
> > you're entirely wrong.
> 
> I would guess that one of the times to use macros is "when you have to
> be portable to compilers that don't have inline functions".  That's
> definitely a key application.

gmp is well into version 4; I doubt it would compile where there is no
support for inline functions, but I have not verified this.



Regards,

Uncle Steve

-- 
Should a professional politician be charged with molestation if he
kisses babies while attending political rallies?

[toc] | [prev] | [next] | [standalone]


#4633

FromSeebs <usenet-nospam@seebs.net>
Date2011-05-23 23:57 +0000
Message-ID<slrnitlsvd.19ga.usenet-nospam@guild.seebs.net>
In reply to#4626
On 2011-05-23, Uncle Steve <stevet810@gmail.com> wrote:
> On Mon, May 23, 2011 at 10:24:31PM +0000, Seebs wrote:
>> On 2011-05-23, Uncle Steve <stevet810@gmail.com> wrote:
>> > There are no "user defined" types in C.

>> Sure there are!

> Oh, no there aren't!

Well, I'll qualify it:

There are rules in C for defining things which the language calls
"types" and which participate fully in the general C rules about type
aliasing and type safety.

>> So?  Doesn't make them not types.  Pointers, arrays, enums, structs,
>> unions... all types.  Structs and unions are user-defined.  And they are
>> types.  This makes them... *drumroll* user-defined types.

> Not if we make a finer distinction between types.

That distinction is *within* the category of "types", though.

> char, int, long, float, void *, etc. are /basic types/ fundamental to
> the implementation of the C language (and arithmetic operations).
> Compound types are aggregates of these basic types as well as compound
> types.  There's a fundamental difference you are ignoring given a
> sufficient vague definition of 'type'.

No, I'm not ignoring that difference.  I'm stating that it is a difference
between some types and other types; between basic types and derived types,
say.  Or basic types and aggregate types.

But aggregate types are still types!

> A real user-defined type would be something new like the complex
> numbers extension in gcc.

No, that would be a new user-defined *basic* type.  The word "type" has
a very rigorous meaning in C, and aggregate types are types, and user-defined
types exist.  That only some kinds of types can be user-defined doesn't
change that.

>> I would guess that one of the times to use macros is "when you have to
>> be portable to compilers that don't have inline functions".  That's
>> definitely a key application.

> gmp is well into version 4; I doubt it would compile where there is no
> support for inline functions, but I have not verified this.

As pointed out:  gmp is part of the bootstrap process for gcc.  It compiles
on pretty old stuff, by necessity.

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

[toc] | [prev] | [next] | [standalone]


#4643

FromUncle Steve <stevet810@gmail.com>
Date2011-05-23 21:22 -0400
Message-ID<5936f04f8e60065-d6df3@gmail.com>
In reply to#4633
On Mon, May 23, 2011 at 11:57:10PM +0000, Seebs wrote:
> On 2011-05-23, Uncle Steve <stevet810@gmail.com> wrote:
> > On Mon, May 23, 2011 at 10:24:31PM +0000, Seebs wrote:
> >> On 2011-05-23, Uncle Steve <stevet810@gmail.com> wrote:
> >> > There are no "user defined" types in C.
> 
> >> Sure there are!
> 
> > Oh, no there aren't!
> 
> Well, I'll qualify it:
> 
> There are rules in C for defining things which the language calls
> "types" and which participate fully in the general C rules about type
> aliasing and type safety.
> 
> >> So?  Doesn't make them not types.  Pointers, arrays, enums, structs,
> >> unions... all types.  Structs and unions are user-defined.  And they are
> >> types.  This makes them... *drumroll* user-defined types.
> 
> > Not if we make a finer distinction between types.
> 
> That distinction is *within* the category of "types", though.

Absolutely correct, but I think it may be an error to use the word
"type" to mean several different things:  'basic' types,
aggregates of basic types, enumerated types, unions, structures, and
function definitions.  All these things have wildly different
semantics and varying syntax.  They aren't all interchangable, and
therefore are differing entities.  We say 'type', but the definition
changes depending on what we are discussing.
 
> > char, int, long, float, void *, etc. are /basic types/ fundamental to
> > the implementation of the C language (and arithmetic operations).
> > Compound types are aggregates of these basic types as well as compound
> > types.  There's a fundamental difference you are ignoring given a
> > sufficient vague definition of 'type'.
> 
> No, I'm not ignoring that difference.  I'm stating that it is a difference
> between some types and other types; between basic types and derived types,
> say.  Or basic types and aggregate types.
> 
> But aggregate types are still types!

I have no real argument there except to say that an aggregate type is
not the same thing as a basic type, even if the way they are used in a
program can be similar.  For instance, everyone knows that the address
of an integer, float, structure, or function can be taken.  Yet, I
cannot perform addition on functions.  They are different things.
 
> > A real user-defined type would be something new like the complex
> > numbers extension in gcc.
> 
> No, that would be a new user-defined *basic* type.  The word "type" has
> a very rigorous meaning in C, and aggregate types are types, and user-defined
> types exist.  That only some kinds of types can be user-defined doesn't
> change that.

Again, there is a huge qualitative difference between defining a new
integer type and a structure type.  
 
> >> I would guess that one of the times to use macros is "when you have to
> >> be portable to compilers that don't have inline functions".  That's
> >> definitely a key application.
> 
> > gmp is well into version 4; I doubt it would compile where there is no
> > support for inline functions, but I have not verified this.
> 
> As pointed out:  gmp is part of the bootstrap process for gcc.  It compiles
> on pretty old stuff, by necessity.

Which version of gmp does gcc use these days to support those old
platforms?



Regards,

Uncle Steve

-- 
Should a professional politician be charged with molestation if he
kisses babies while attending political rallies?

[toc] | [prev] | [next] | [standalone]


#4659

FromSeebs <usenet-nospam@seebs.net>
Date2011-05-24 03:46 +0000
Message-ID<slrnitm8vt.1ldu.usenet-nospam@guild.seebs.net>
In reply to#4643
On 2011-05-24, Uncle Steve <stevet810@gmail.com> wrote:
> Absolutely correct, but I think it may be an error to use the word
> "type" to mean several different things:  'basic' types,
> aggregates of basic types, enumerated types, unions, structures, and
> function definitions.  All these things have wildly different
> semantics and varying syntax.  They aren't all interchangable, and
> therefore are differing entities.  We say 'type', but the definition
> changes depending on what we are discussing.

No, it doesn't.  The word "type" denotes the category into which all
of those things fit.

It's like "number".  The word "number" includes rationals and irrationals
and complexes and counting numbers... so what?  It's a good word because
it lets us characterize the stuff they have in common.

All the "types" have things in common in terms of their meaning to the
C type system.

> I have no real argument there except to say that an aggregate type is
> not the same thing as a basic type,

That's right.

> even if the way they are used in a
> program can be similar.  For instance, everyone knows that the address
> of an integer, float, structure, or function can be taken.  Yet, I
> cannot perform addition on functions.  They are different things.

Right.  That is because function pointer types are not object pointer types.

But function types and object types still have underlying commonalities.
It is useful to refer to those commonalities in some way; we use the word
"type".

> Again, there is a huge qualitative difference between defining a new
> integer type and a structure type.  

Sure.

But they are differences *within* the concept of "defining a type".

>> As pointed out:  gmp is part of the bootstrap process for gcc.  It compiles
>> on pretty old stuff, by necessity.

> Which version of gmp does gcc use these days to support those old
> platforms?

gcc 4.4 requires GMP 4.1+ and MPFR 2.3.2+.

Just to clarify:  My day job is toolchain tech lead.  The actual hard
compiler stuff is outsourced to Code Sourcery (who are awesome), but I do
maintain a certain basic familiarity with compiler build stuff.  Long
story short, the core tools like this are only relatively recently (I
think it's a gcc 4 decision) willing to assume that they have access to a
compiler which supports prototypes.

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

[toc] | [prev] | [next] | [standalone]


#4667

FromUncle Steve <stevet810@gmail.com>
Date2011-05-24 00:24 -0400
Message-ID<44ec339c84ce72a-9f787@gmail.com>
In reply to#4659
On Tue, May 24, 2011 at 03:46:54AM +0000, Seebs wrote:
> On 2011-05-24, Uncle Steve <stevet810@gmail.com> wrote:
> > Absolutely correct, but I think it may be an error to use the word
> > "type" to mean several different things:  'basic' types,
> > aggregates of basic types, enumerated types, unions, structures, and
> > function definitions.  All these things have wildly different
> > semantics and varying syntax.  They aren't all interchangable, and
> > therefore are differing entities.  We say 'type', but the definition
> > changes depending on what we are discussing.
> 
> No, it doesn't.  The word "type" denotes the category into which all
> of those things fit.
> 
> It's like "number".  The word "number" includes rationals and irrationals
> and complexes and counting numbers... so what?  It's a good word because
> it lets us characterize the stuff they have in common.

Until we trip over the hidden differences.
 
> All the "types" have things in common in terms of their meaning to the
> C type system.

True.  It's all about variables and differentiating them from each
other.  
 
> > I have no real argument there except to say that an aggregate type is
> > not the same thing as a basic type,
> 
> That's right.
> 
> > even if the way they are used in a
> > program can be similar.  For instance, everyone knows that the address
> > of an integer, float, structure, or function can be taken.  Yet, I
> > cannot perform addition on functions.  They are different things.
> 
> Right.  That is because function pointer types are not object pointer types.
> 
> But function types and object types still have underlying commonalities.
> It is useful to refer to those commonalities in some way; we use the word
> "type".

Yes, I noticed that.

> > Again, there is a huge qualitative difference between defining a new
> > integer type and a structure type.  
> 
> Sure.
> 
> But they are differences *within* the concept of "defining a type".

True, however the bare 'type' nomenclature conceals the differences,
which are perhaps only of non-trivial interest to compiler-writers.
 
> >> As pointed out:  gmp is part of the bootstrap process for gcc.  It compiles
> >> on pretty old stuff, by necessity.
> 
> > Which version of gmp does gcc use these days to support those old
> > platforms?
> 
> gcc 4.4 requires GMP 4.1+ and MPFR 2.3.2+.
> 
> Just to clarify:  My day job is toolchain tech lead.  The actual hard
> compiler stuff is outsourced to Code Sourcery (who are awesome), but I do
> maintain a certain basic familiarity with compiler build stuff.  Long
> story short, the core tools like this are only relatively recently (I
> think it's a gcc 4 decision) willing to assume that they have access to a
> compiler which supports prototypes.

So gcc 3 and earlier will compile stage one on such a compiler?  That
is scary.  I think I saw one of those compilers back in the beginning
of the nineties on the Amiga: Dice, Manx or Lattice C; I no longer
recall the details.  Never did much programming back then, and anyways
the code I wrote is long gone.



Regards,

Uncle Steve

-- 
Should a professional politician be charged with molestation if he
kisses babies while attending political rallies?

[toc] | [prev] | [next] | [standalone]


#4670

FromSeebs <usenet-nospam@seebs.net>
Date2011-05-24 04:44 +0000
Message-ID<slrnitmdla.1oni.usenet-nospam@guild.seebs.net>
In reply to#4667
On 2011-05-24, Uncle Steve <stevet810@gmail.com> wrote:
> On Tue, May 24, 2011 at 03:46:54AM +0000, Seebs wrote:
>> It's like "number".  The word "number" includes rationals and irrationals
>> and complexes and counting numbers... so what?  It's a good word because
>> it lets us characterize the stuff they have in common.

> Until we trip over the hidden differences.

I don't think the differences are hidden -- as long as you realize that
"type" is a very broad term in C, and doesn't carry all the extra
meanings of "basic type".  Which is why the standard defines terms
for things like "basic types" and "derived types".

> True, however the bare 'type' nomenclature conceals the differences,
> which are perhaps only of non-trivial interest to compiler-writers.

I don't think it conceals them, it just doesn't refer to them.  When I
refer to someone as "human", I'm not "concealing" the differences between
men and women, or between people who do and don't have cancer.  I'm just
not talking about those differences.

> So gcc 3 and earlier will compile stage one on such a compiler?  That
> is scary.  I think I saw one of those compilers back in the beginning
> of the nineties on the Amiga: Dice, Manx or Lattice C; I no longer
> recall the details.  Never did much programming back then, and anyways
> the code I wrote is long gone.

Manx and Lattice, at least, supported prototypes when I used them.

Honestly, I think it pretty much comes down to "default compilers shipped
with some commercial Unix systems".

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

[toc] | [prev] | [next] | [standalone]


#4690

Frompete <pfiland@mindspring.com>
Date2011-05-24 07:46 -0400
Message-ID<4DDB9A9B.57D5@mindspring.com>
In reply to#4667
Uncle Steve wrote:
> 
> On Tue, May 24, 2011 at 03:46:54AM +0000, Seebs wrote:
 
> > All the "types" have things in common
> > in terms of their meaning to the C type system.
> 
> True.  It's all about variables and differentiating them from each
> other.

Not just variables:
0
0u
0lu
0.0
0.0f

-1 > 0U
-1 < 0L

Every expression has a type.

-- 
pete

[toc] | [prev] | [next] | [standalone]


#4691

FromJames Kuyper <jameskuyper@verizon.net>
Date2011-05-24 07:48 -0400
Message-ID<irg5uv$409$1@dont-email.me>
In reply to#4643
On 05/23/2011 09:22 PM, Uncle Steve wrote:
> On Mon, May 23, 2011 at 11:57:10PM +0000, Seebs wrote:
>> On 2011-05-23, Uncle Steve <stevet810@gmail.com> wrote:
>>> On Mon, May 23, 2011 at 10:24:31PM +0000, Seebs wrote:
>>>> On 2011-05-23, Uncle Steve <stevet810@gmail.com> wrote:
>>>>> There are no "user defined" types in C.
>>
>>>> Sure there are!
...
>>>> So?  Doesn't make them not types.  Pointers, arrays, enums, structs,
>>>> unions... all types.  Structs and unions are user-defined.  And they are
>>>> types.  This makes them... *drumroll* user-defined types.
>>
>>> Not if we make a finer distinction between types.
>>
>> That distinction is *within* the category of "types", though.
> 
> Absolutely correct, but I think it may be an error to use the word
> "type" to mean several different things:  'basic' types,
> aggregates of basic types, enumerated types, unions, structures, and
> function definitions.

You might feel that way, but if you wish to communicate clearly with
people about C, you need to use the term 'type' in a way consistent with
it's definition by the C standard. You can reasonable argue that the
definition should be changed (though such a suggestion is more usefully
discussed on comp.std.c). However, using the word 'type' in a way that
is inconsistent with the definition provided by the C standard, serves
only to confuse people who are familiar with that definition.

The correct way, within a C context, to say what you want to say, is
"There are no user-defined basic types in C". It's a perfectly true,
utterly non-controversial statement, and also one that would be
completely irrelevant in the context where you said, incorrectly, "There
are no user-defined types in C".

> ... All these things have wildly different
> semantics and varying syntax.  They aren't all interchangable, and

They are interchangeable within every context in which the C standard
uses the term "type" without modification.

-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#4615

FromIan Collins <ian-news@hotmail.com>
Date2011-05-24 10:35 +1200
Message-ID<9405q4Ft2pU12@mid.individual.net>
In reply to#4606
On 05/24/11 09:53 AM, Uncle Steve wrote:
> On Tue, May 24, 2011 at 09:25:29AM +1200, Ian Collins wrote:
>> On 05/24/11 08:51 AM, Uncle Steve wrote:
>>> On Mon, May 23, 2011 at 07:45:24PM +0000, Seebs wrote:
>>>> On 2011-05-23, Keith Thompson<kst-u@mib.org>   wrote:
>>>>> Just a quibble: size_t may be exactly the same type as unsigned long,
>>>>> since a typedef merely creates an alias for an existing type, not
>>>>> a new and distinct type.  plain char and signed char (for example)
>>>>> are distinct in a way that size_t and unsigned long (for example)
>>>>> are not.
>>>>
>>>> True.  Although, possibly confusingly, there are places where it seems
>>>> that the thing a typedef creates is itself then called "a type".  The
>>>> wording is a bit fuzzy.
>>>>
>>>> We all know what we mean, I think.  You could say it several ways:
>>>>
>>>> 	Typedef does not actually create types; instead, it creates
>>>> 	names which refer to existing types.
>>>>
>>>> 	Typedef creates types, but those types are identical to existing
>>>> 	types and can be used interchangably with them.
>>>
>>> How about the idea that typedefs create aliases for the basic built-in
>>> types supplied by the language spec.?
>>
>> A typedef may provide an alias to any existing type, built-in, user
>> defined or even incomplete.
>
> There are no "user defined" types in C.

If they aren't defined buy programmers, who are they defined by?

> Structures and unions are
> aggregates of basic types (and structures/unions).

Well if you want to be pedantic, unions aren't aggregate types because 
they can only contain one member at a time.

Let's expand the above for completeness:

A typedef may provide an alias to any existing type, built-in, 
aggregate, union, composite or even incomplete.

There, did I leave anything out?

> I believe
> incomplete types are a (usually temporary) artifact of the compilation
> process and you won't ever see them in a running program.

Have you ever used void*?  What about a library with an opaque handle type?

> BTW, have a look at the gmp.h header and note that they do not shy
> away from macro-like functions.  Not that I care a whole lot, but I'd
> say the writers of the gmp library probably know more than you do
> about the suitability of inline functions versus macros and when to
> use each.  Just a 'feeling' on the matter, which is not to say that
> you're entirely wrong.

gmp has been around for a long time, well before inline function support 
was common in C compilers (or even standardised).

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#4617

FromSeebs <usenet-nospam@seebs.net>
Date2011-05-23 22:38 +0000
Message-ID<slrnitlohk.15f2.usenet-nospam@guild.seebs.net>
In reply to#4615
On 2011-05-23, Ian Collins <ian-news@hotmail.com> wrote:
> gmp has been around for a long time, well before inline function support 
> was common in C compilers (or even standardised).

More importantly:

gmp is used by gcc.

gcc has a strictly dogmatic requirement that you don't need a very good
or modern compiler to build it.

Therefore gmp must be buildable with a very old compiler.

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

[toc] | [prev] | [next] | [standalone]


#4619

FromIan Collins <ian-news@hotmail.com>
Date2011-05-24 10:53 +1200
Message-ID<9406r5Ft2pU14@mid.individual.net>
In reply to#4617
On 05/24/11 10:38 AM, Seebs wrote:
> On 2011-05-23, Ian Collins<ian-news@hotmail.com>  wrote:
>> gmp has been around for a long time, well before inline function support
>> was common in C compilers (or even standardised).
>
> More importantly:
>
> gmp is used by gcc.
>
> gcc has a strictly dogmatic requirement that you don't need a very good
> or modern compiler to build it.

Isn't that just for the bootstrap phase of the build?  Once it's past 
that, it can build its self.

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#4621

FromSeebs <usenet-nospam@seebs.net>
Date2011-05-23 23:17 +0000
Message-ID<slrnitlq7d.17av.usenet-nospam@guild.seebs.net>
In reply to#4619
On 2011-05-23, Ian Collins <ian-news@hotmail.com> wrote:
> Isn't that just for the bootstrap phase of the build?  Once it's past 
> that, it can build its self.

Yes.  But gmp is built first for the bootstrap phase.  (At least... It
is in the version I maintain build scripts for.  I assume the clever folks
at Code Sourcery know what they're doing.)

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

[toc] | [prev] | [next] | [standalone]


#4622

FromIan Collins <ian-news@hotmail.com>
Date2011-05-24 11:24 +1200
Message-ID<9408kkFt2pU17@mid.individual.net>
In reply to#4621
On 05/24/11 11:17 AM, Seebs wrote:
> On 2011-05-23, Ian Collins<ian-news@hotmail.com>  wrote:
>> Isn't that just for the bootstrap phase of the build?  Once it's past
>> that, it can build its self.
>
> Yes.  But gmp is built first for the bootstrap phase.  (At least... It
> is in the version I maintain build scripts for.  I assume the clever folks
> at Code Sourcery know what they're doing.)

OK, that surprises me.  I wonder why building a compiler requires gmp?

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#4625

FromSeebs <usenet-nospam@seebs.net>
Date2011-05-23 23:39 +0000
Message-ID<slrnitlr6m.18av.usenet-nospam@guild.seebs.net>
In reply to#4622
On 2011-05-23, Ian Collins <ian-news@hotmail.com> wrote:
> On 05/24/11 11:17 AM, Seebs wrote:
>> Yes.  But gmp is built first for the bootstrap phase.  (At least... It
>> is in the version I maintain build scripts for.  I assume the clever folks
>> at Code Sourcery know what they're doing.)

> OK, that surprises me.  I wonder why building a compiler requires gmp?

My guess is for preprocessor arithmetic, which has to be implemented
reliably in the largest type available on the target, which may not be the
host.  You can cross-compile from a 32-bit machine to a 64-bit, so the
preprocessor has to be able to do 64-bit math.

Using gmp is probably a lot simpler than writing another thing just like
it.  :)

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

[toc] | [prev] | [next] | [standalone]


#4685

Fromjacob navia <jacob@spamsink.net>
Date2011-05-24 11:23 +0200
Message-ID<irfte6$r79$1@speranza.aioe.org>
In reply to#4625
Le 24/05/11 01:39, Seebs a écrit :
> On 2011-05-23, Ian Collins<ian-news@hotmail.com>  wrote:
>> On 05/24/11 11:17 AM, Seebs wrote:
>>> Yes.  But gmp is built first for the bootstrap phase.  (At least... It
>>> is in the version I maintain build scripts for.  I assume the clever folks
>>> at Code Sourcery know what they're doing.)
>
>> OK, that surprises me.  I wonder why building a compiler requires gmp?
>
> My guess is for preprocessor arithmetic, which has to be implemented
> reliably in the largest type available on the target, which may not be the
> host.  You can cross-compile from a 32-bit machine to a 64-bit, so the
> preprocessor has to be able to do 64-bit math.
>
> Using gmp is probably a lot simpler than writing another thing just like
> it.  :)
>
> -s

Gcc had a multiple precision package for that purpose. It was simple and
efficient and never gave any problems, all features that made it obsolete.

Why make it simple when you can make it very complicated?

They now use GMP, a HUGE package that can multiply numbers of ANY
size, up to thousands of digits precision, complete with assembler
code tailored for each processor, with obscure macros, with  thousands
of complications that aren't at all needed for a compiler.

That is progress my friend. PROGRESS means:

If it is simple, it is wrong.

[toc] | [prev] | [next] | [standalone]


#4701

FromKeith Thompson <kst-u@mib.org>
Date2011-05-24 08:46 -0700
Message-ID<lntyckyubw.fsf@nuthaus.mib.org>
In reply to#4685
jacob navia <jacob@spamsink.net> writes:
[...]
> Gcc had a multiple precision package for that purpose. It was simple and
> efficient and never gave any problems, all features that made it obsolete.
>
> Why make it simple when you can make it very complicated?
>
> They now use GMP, a HUGE package that can multiply numbers of ANY
> size, up to thousands of digits precision, complete with assembler
> code tailored for each processor, with obscure macros, with  thousands
> of complications that aren't at all needed for a compiler.
>
> That is progress my friend. PROGRESS means:
>
> If it is simple, it is wrong.

If GMP had been developed specifically to be used by gcc, and
not used in other contexts, I'd probably agree with you; using an
infinite-precision library where, say, 128 bits would be enough
would be overkill (assuming the 128-bit library is simpler than the
infinite-=precision library).

But GMP already exists, and all the effort needed to develop
it has already been expended.  The complexity of GMP is huge.
The complexity of adding GMP to gcc is minimal.  And it has the
benefit that the previous multiple precision package is no longer
required, no longer needs to be maintained, and is no longer a
potential additional source of bugs.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#4705

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2011-05-24 09:14 -0700
Message-ID<549cf38c-6e72-48b1-80c0-b81c89667c8a@14g2000yqo.googlegroups.com>
In reply to#4701
On May 24, 6:46 pm, Keith Thompson <ks...@mib.org> wrote:
> The complexity of GMP is huge.
> The complexity of adding GMP to gcc is minimal.
>
In comparison to the complexity of developing such a package from
scratch, yes.

But installation of C libraries is a huge problem. Just little things
like the bool problem can turn into major headaches. Then you've got
to supply the library to anyone to whom ypu give source code, which
can quickly turn into having two or more copies of the library on the
machine.
--
MiniBasic - how to write a script interpreter
http://www.lulu.com/~bgy1mm

[toc] | [prev] | [next] | [standalone]


#4975

FromMichael Press <rubrum@pacbell.net>
Date2011-05-28 21:50 -0700
Message-ID<rubrum-3AA665.21503928052011@news.albasani.net>
In reply to#4617
In article <slrnitlohk.15f2.usenet-nospam@guild.seebs.net>,
 Seebs <usenet-nospam@seebs.net> wrote:

> On 2011-05-23, Ian Collins <ian-news@hotmail.com> wrote:
> > gmp has been around for a long time, well before inline function support 
> > was common in C compilers (or even standardised).
> 
> More importantly:
> 
> gmp is used by gcc.
> 
> gcc has a strictly dogmatic requirement that you don't need a very good
> or modern compiler to build it.

What is the dogma?

-- 
Michael Press

[toc] | [prev] | [next] | [standalone]


Page 3 of 7 — ← Prev page 1 2 [3] 4 5 6 7  Next page →

Back to top | Article view | comp.lang.c


csiph-web