Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
good to have typedef?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  19 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
doublemaster007@gmail.com  
View profile  
 More options Oct 31, 8:31 am
Newsgroups: comp.lang.c++
From: "doublemaster...@gmail.com" <doublemaster...@gmail.com>
Date: Fri, 30 Oct 2009 14:01:10 -0700 (PDT)
Local: Sat, Oct 31 2009 8:31 am
Subject: good to have typedef?
Is it good to typedef the types?? What is the actual use of it? I am
working on project where tooo many typedefs are used..If many people
are working on a project..only the person who defined will be
remembering it..finally too many typedefs will be there and code
becomes hard to use...

So i wanna know..is typedefs are really useful in full fledged
project??


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Champ  
View profile  
 More options Oct 31, 8:42 am
Newsgroups: comp.lang.c++
From: Andy Champ <no....@nospam.invalid>
Date: Fri, 30 Oct 2009 21:12:33 +0000
Local: Sat, Oct 31 2009 8:42 am
Subject: Re: good to have typedef?

doublemaster...@gmail.com wrote:
> Is it good to typedef the types?? What is the actual use of it? I am
> working on project where tooo many typedefs are used..If many people
> are working on a project..only the person who defined will be
> remembering it..finally too many typedefs will be there and code
> becomes hard to use...

> So i wanna know..is typedefs are really useful in full fledged
> project??

Sometimes.

No really, that's the only answer.

On the one side, it's a pain to have to remember to type

std::map<somesortofKeyType, SomeSortofValue, somesortthing>::iterator

whenever you want to look in your collection of values, when "ValueIter"
would work.

OTOH, sometimes you have to chase back and find out what all those
things are.

I'm guessing you're new on the project.  Best talk to someone, and ask
them why.

Andy


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Johannes Schaub (litb)  
View profile  
 More options Oct 31, 11:06 am
Newsgroups: comp.lang.c++
Followup-To: comp.lang.c++
From: "Johannes Schaub (litb)" <schaub-johan...@web.de>
Date: Sat, 31 Oct 2009 00:36:15 +0100
Local: Sat, Oct 31 2009 11:06 am
Subject: Re: good to have typedef?

doublemaster...@gmail.com wrote:
> Is it good to typedef the types?? What is the actual use of it? I am
> working on project where tooo many typedefs are used..If many people
> are working on a project..only the person who defined will be
> remembering it..finally too many typedefs will be there and code
> becomes hard to use...

Sometimes, you can make better use of identity than of typedef. For example
to make a pointer to an array, and you want to use a typedef, you can
instead use identity

identity<int[5]>::type *ptr;

I've seen that identity has lots of nice uses, where otherwise a typedef
would have to be used to make things easy to read. The above would look like
the below with typedef

typedef int array_type[5];
array_type *ptr;

And i think using identity, this looks and feels better.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard  
View profile  
 More options Oct 31, 2:07 pm
Newsgroups: comp.lang.c++
From: legalize+jee...@mail.xmission.com (Richard)
Date: Sat, 31 Oct 2009 02:37:29 +0000 (UTC)
Local: Sat, Oct 31 2009 2:07 pm
Subject: Re: good to have typedef?
[Please do not mail me a copy of your followup]

"doublemaster...@gmail.com" <doublemaster...@gmail.com> spake the secret code
<72babf2c-fbba-4612-9f0a-958a37596...@f1g2000prf.googlegroups.com> thusly:

>So i wanna know..is typedefs are really useful in full fledged
>project??

Like anything in your code, you should use them if they add value and
avoid them if they are not carrying their weight.

Its possible to overuse typedefs to the point where they fail to
provide value.

For instance, I personally don't find value in typedefs like this:

    typedef std::string *stringPtr;

Particularly since using that typedef leads you down the problem of
improperly specifying pointers to const strings.  People think its
this:

    const stringPtr unchangedStringThroughPointer;

Unfortunately you didn't specify the string was const, but that the
pointer was const.  That's why Windows headers have the typedefs LPSTR
and LPCSTR, with the former being pointer to char and the latter being
pointer to const char.  (The LP business is just an anachronism from
Win16 days.)  Is LPSTR really more clear than char *?  Is LPCSTR
really more clear than char const *?  I don't think so, but I'll use
those typedefs because they are pervasive in Windows and Windows
programmers are familiar enough with them to know what they mean.  I
stop short of using things like LPDIRECT3DDEVICE9 instead of
IDirect3DDevice9 *.  The former just feels like screaming to me, while
the latter is easier to read and is just as clear (in context) that
we're talking about a COM interface pointer.

I'm currently working on a code base that is replete with typedefs
like these:

    typedef unsigned char uint8;
    typedef int int32;
    typedef unsigned int uint32;
    typedef float real;
    typedef double lreal;

and so-on.

Personally I don't like declaring my types as having a bit size unless
it is truly relevant to their role.  Once *everything* is declared as
an int32, how do you know which ones *really* need 32-bits and which
ones are comfortable in the native size of int?  If you really need to
guarantee that an int is at least 32-bits you can do this in other
ways than polluting the entire source base with spurious int32's
everywhere.

The real/lreal thing is particularly annoying.  It just obfuscates the
code in an attemp to abstract away a coupling to an implementation
dependency, yet it fails to do so in any meaningful way because it is
just an alias for an implementation dependency instead of an
abstraction like a new type (i.e. a class) would do.  Because the
built-in types like int, float and double can't be extended or
customized, the typedef doesn't carry its own weight.  It obscures the
fact that you *are* coupled to the implementation details of a float
or a double, while at the same time pretending to decouple you from
those details.  It adds no value and reduces the clarity of the code.

The one area where typedefs are most useful is in consuming template
classes.  std::string::find returns std::string::size_type; if I'm
using that type repeatedly in a function its easier to create a local
typedef for it:

void wipeOutSlashes(std::string &text)
{
    typedef std::string::size_type size_type;

    // declare locals of type size_type

}

That's just a simple example.  It gets more useful when declaring
iterators and other types related to a template class.  If you are
writing template libraries, creating nested typedefs that refer to
related types in your base class or in the template argument are very
useful for making the template expansion more readable.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
 <http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/>

      Legalize Adulthood! <http://legalizeadulthood.wordpress.com>


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Saeed Amrollahi  
View profile  
 More options Oct 31, 10:10 pm
Newsgroups: comp.lang.c++
From: Saeed Amrollahi <amrollahi.sa...@gmail.com>
Date: Sat, 31 Oct 2009 03:40:59 -0700 (PDT)
Local: Sat, Oct 31 2009 10:10 pm
Subject: Re: good to have typedef?
On Oct 31, 12:01 am, "doublemaster...@gmail.com"

<doublemaster...@gmail.com> wrote:
> Is it good to typedef the types?? What is the actual use of it? I am
> working on project where tooo many typedefs are used..If many people
> are working on a project..only the person who defined will be
> remembering it..finally too many typedefs will be there and code
> becomes hard to use...

> So i wanna know..is typedefs are really useful in full fledged
> project??

Hi

Just my two cents ...
In addition to what Richard wrote, sometimes typedef declaration is
almost necessary.
For example, in C++ standard library, there are a lot of typedef
declarations
inside declaration/defintion of containers. A typical typedef is a
another
name for template parameter:
   template<class T> // the bare bones
   class std::list {
     // ...
     typedef T value_type;
     // ...
   };
So, we can use the template parameter:
   void f(list<T>& L)
   {
     typename list<T>::value_type v = *v.begin();
     // ...
   }
without such typedef we can't use template parameter in generic
manner.
Also the keyword "typename" in above line is necessary.

Regards,
  -- Saeed Amrollahi


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorgen Grahn  
View profile  
 More options Nov 5, 9:49 am
Newsgroups: comp.lang.c++
From: Jorgen Grahn <grahn+n...@snipabacken.se>
Date: 4 Nov 2009 22:19:19 GMT
Local: Thurs, Nov 5 2009 9:49 am
Subject: Re: good to have typedef?

On Fri, 2009-10-30, doublemaster...@gmail.com wrote:
> Is it good to typedef the types?? What is the actual use of it? I am
> working on project where tooo many typedefs are used..If many people
> are working on a project..only the person who defined will be
> remembering it..finally too many typedefs will be there and code
> becomes hard to use...

I have to say that doesn't make sense to me.  It's hard to see what
the problem is with your code.

> So i wanna know..is typedefs are really useful in full fledged
> project??

I agree with "Richard" elsewhere in this thread. And also:

- Most people, I think, dislike when a typedef is used to try to hide
  that something is a struct or a pointer. Like, having to type FooPtr
  instead of Foo*. I think Richard mentioned why that is not only
  annoying but also harmful.

- Projects often overuse CHAR, UCHAR, uint32, etc ... typedefs.
  Not a plain char or int in sight. I hate that.

- Typedefs are just aliases; they don't buy you type safety.
  You might have
     typedef std::string PersonName;
     typedef std::string Gender;
  and still mix up the arguments to
     void DatingService::add(const PersonName&, const Gender&);
  In other words, that prototype adds *no* value compared to
  one where the arguments are const std::string&.

Is your problem one of these?

/Jorgen

--
  // Jorgen Grahn <grahn@  Oo  o.   .  .
\X/     snipabacken.se>   O  o   .


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Champ  
View profile  
 More options Nov 5, 10:36 am
Newsgroups: comp.lang.c++
From: Andy Champ <no....@nospam.invalid>
Date: Wed, 04 Nov 2009 23:06:02 +0000
Local: Thurs, Nov 5 2009 10:36 am
Subject: Re: good to have typedef?
Jorgen Grahn wrote:

<snip>
> - Projects often overuse CHAR, UCHAR, uint32, etc ... typedefs.
>   Not a plain char or int in sight. I hate that.

</snip>

We've got an awful lot of uint32_t in our project.  That's because it
represents a data item which, because of published specifications, is 32
bits, no more, no less.

int is a word size which is convenient for the machine - good for
loopcounts, but not for precise data mappings.

Andy


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Kanze  
View profile  
 More options Nov 5, 8:07 pm
Newsgroups: comp.lang.c++
From: James Kanze <james.ka...@gmail.com>
Date: Thu, 5 Nov 2009 00:37:37 -0800 (PST)
Local: Thurs, Nov 5 2009 8:07 pm
Subject: Re: good to have typedef?
On Nov 4, 11:06 pm, Andy Champ <no....@nospam.invalid> wrote:

> Jorgen Grahn wrote:
> <snip>> - Projects often overuse CHAR, UCHAR, uint32, etc ... typedefs.
> >   Not a plain char or int in sight. I hate that.
> </snip>
> We've got an awful lot of uint32_t in our project.  That's
> because it represents a data item which, because of published
> specifications, is 32 bits, no more, no less.

I'm curious.  What published specifications impose anything
concerning the internal representation?  (Externally, of course,
the published specifications probably impose more than just 32
bits.  Like byte order, for example.)

> int is a word size which is convenient for the machine - good
> for loopcounts, but not for precise data mappings.

That's not it's role.  When you need to input or output data in
a precise format, you write code to do so: int32_t and others
aren't directly applicable here.  (Indirectly... if you're
willing to restrict your portability to machines where uint32_t
is available---and that's still a lot of them---, then using it
for certain intermediate representations can make your code
significantly simpler.)

--
James Kanze


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nick Keighley  
View profile  
 More options Nov 5, 9:27 pm
Newsgroups: comp.lang.c++
From: Nick Keighley <nick_keighley_nos...@hotmail.com>
Date: Thu, 5 Nov 2009 01:57:25 -0800 (PST)
Local: Thurs, Nov 5 2009 9:27 pm
Subject: Re: good to have typedef?
On 4 Nov, 22:19, Jorgen Grahn <grahn+n...@snipabacken.se> wrote:

> On Fri, 2009-10-30, doublemaster...@gmail.com wrote:
> > Is it good to typedef the types?? What is the actual use of it? I am
> > working on project where tooo many typedefs are used..If many people
> > are working on a project..only the person who defined will be
> > remembering it..finally too many typedefs will be there and code
> > becomes hard to use...

get a decent source browser. I agree typedefs can be over-used but the
they can be under-used as well.

<snip>

> - Most people, I think, dislike when a typedef is used to try to hide
>   that something is a struct or a pointer.

I've no objection to hiding a struct behind a typedef (or at least in
C becasue I hate scattering the "struct" keyword all over the place
(I'm aware C++ doesn't have this problem)). I'm almost with you on
pointers except I justify hungarian for smart pointers. This is one of
the few places I'd advocate hungarian because I /want/ my nose rubbed
in what-type-of-pointer is this to make sure I cleanup properly.

> Like, having to type FooPtr
>   instead of Foo*. I think Richard mentioned why that is not only
>   annoying but also harmful.

oh, I agree. Then there's hiding arrays (but C++ programmers don't use
arrays  :-) )

> - Projects often overuse CHAR, UCHAR, uint32, etc ... typedefs.
>   Not a plain char or int in sight. I hate that.

yuk. I've worked on projects where the programmming standards said you
must not use raw types. And the configuration control system
checked.  :-(

Lovely bug:-

   Station_id read_station_id (FILE *in)
   {
      Station_id station_id;
      fscanf (in, "%d", &station_id);
      return station_id;
   }

Station_id was a short.

> - Typedefs are just aliases; they don't buy you type safety.

too true. Possibly one of C's design mistakes.

>   You might have
>      typedef std::string PersonName;
>      typedef std::string Gender;
>   and still mix up the arguments to
>      void DatingService::add(const PersonName&, const Gender&);
>   In other words, that prototype adds *no* value compared to
>   one where the arguments are const std::string&.

it documents intent. I'd maybe write

void DatingService::add(const std::string &personName&, std::const
string& gender);


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Champ  
View profile  
 More options Nov 6, 8:01 am
Newsgroups: comp.lang.c++
From: Andy Champ <no....@nospam.invalid>
Date: Thu, 05 Nov 2009 20:31:21 +0000
Local: Fri, Nov 6 2009 8:01 am
Subject: Re: good to have typedef?

You've answered your own question - it's a data transfer specification.
  I don't want to say any more than that.

Andy
--
BTW you lost the space after the hyphens in your sig.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Kanze  
View profile  
 More options Nov 6, 9:23 am
Newsgroups: comp.lang.c++
From: James Kanze <james.ka...@gmail.com>
Date: Thu, 5 Nov 2009 13:53:03 -0800 (PST)
Local: Fri, Nov 6 2009 9:23 am
Subject: Re: good to have typedef?
On Nov 5, 9:31 pm, Andy Champ <no....@nospam.invalid> wrote:

In which case, uint32_t doesn't necessarily buy you that much.
(It does restrict portability, however, since it is guaranteed
not to be available on some machines.)

--
James Kanze


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Kanze  
View profile  
 More options Nov 6, 9:33 am
Newsgroups: comp.lang.c++
From: James Kanze <james.ka...@gmail.com>
Date: Thu, 5 Nov 2009 14:03:13 -0800 (PST)
Local: Fri, Nov 6 2009 9:33 am
Subject: Re: good to have typedef?
On Nov 5, 10:57 am, Nick Keighley <nick_keighley_nos...@hotmail.com>
wrote:

> On 4 Nov, 22:19, Jorgen Grahn <grahn+n...@snipabacken.se> wrote:

    [...]

> >   You might have
> >      typedef std::string PersonName;
> >      typedef std::string Gender;
> >   and still mix up the arguments to
> >      void DatingService::add(const PersonName&, const Gender&);
> >   In other words, that prototype adds *no* value compared to
> >   one where the arguments are const std::string&.
> it documents intent. I'd maybe write
> void DatingService::add(const std::string &personName&, std::const
> string& gender);

Why not:

    void DatingService::add( Name const& personName,
                             Gender const& gender );

A Name is more than a string, and a Gender is most likely an
enum.

--
James Kanze


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Champ  
View profile  
 More options Nov 6, 10:19 am
Newsgroups: comp.lang.c++
From: Andy Champ <no....@nospam.invalid>
Date: Thu, 05 Nov 2009 22:49:34 +0000
Local: Fri, Nov 6 2009 10:19 am
Subject: Re: good to have typedef?

James Kanze wrote:

> In which case, uint32_t doesn't necessarily buy you that much.
> (It does restrict portability, however, since it is guaranteed
> not to be available on some machines.)

> --
> James Kanze

Luckily for _me_ I only need to worry about Windoze boxes - albeit 64
bit is likely to come up soon.  And I'm also lucky that my byte order
matches the spec. - not everyone does the ISO 9660 trick of storing a
number in both common orders, it's not space efficient!

But what should I use if I want to represent a guaranteed-to-be-32-bit
quantity?

Andy
--
You still need a space after those hyphens.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Collins  
View profile  
 More options Nov 6, 3:17 pm
Newsgroups: comp.lang.c++
From: Ian Collins <ian-n...@hotmail.com>
Date: Fri, 06 Nov 2009 16:47:25 +1300
Local: Fri, Nov 6 2009 3:17 pm
Subject: Re: good to have typedef?

Andy Champ wrote:
> James Kanze wrote:

>> In which case, uint32_t doesn't necessarily buy you that much.
>> (It does restrict portability, however, since it is guaranteed
>> not to be available on some machines.)

> Luckily for _me_ I only need to worry about Windoze boxes - albeit 64
> bit is likely to come up soon.  And I'm also lucky that my byte order
> matches the spec. - not everyone does the ISO 9660 trick of storing a
> number in both common orders, it's not space efficient!

> But what should I use if I want to represent a guaranteed-to-be-32-bit
> quantity?

uint32_t if the system has it.  If not, define your own.

--
Ian Collins


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Kanze  
View profile  
 More options Nov 6, 8:37 pm
Newsgroups: comp.lang.c++
From: James Kanze <james.ka...@gmail.com>
Date: Fri, 6 Nov 2009 01:07:04 -0800 (PST)
Local: Fri, Nov 6 2009 8:37 pm
Subject: Re: good to have typedef?
On Nov 6, 3:47 am, Ian Collins <ian-n...@hotmail.com> wrote:

> Andy Champ wrote:
> > James Kanze wrote:
> >> In which case, uint32_t doesn't necessarily buy you that
> >> much.  (It does restrict portability, however, since it is
> >> guaranteed not to be available on some machines.)
> > Luckily for _me_ I only need to worry about Windoze boxes -
> > albeit 64 bit is likely to come up soon.  And I'm also lucky
> > that my byte order matches the spec. - not everyone does the
> > ISO 9660 trick of storing a number in both common orders,
> > it's not space efficient!
> > But what should I use if I want to represent a
> > guaranteed-to-be-32-bit quantity?
> uint32_t if the system has it.  If not, define your own.

If he only has to worry about Windows, the system has it.  On
systems which don't have it, however, defining your own might be
a bit difficult, and the type will probably be significantly
slower than one of the built-in types.  (On at least one system,
the built-in unsigned types are significantly slower than the
the signed ones, because the hardware doesn't directly support
them.)

--
James Kanze


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gerhard Fiedler  
View profile  
 More options Nov 8, 6:14 am
Newsgroups: comp.lang.c++
From: Gerhard Fiedler <geli...@gmail.com>
Date: Sat, 7 Nov 2009 16:44:20 -0200
Local: Sun, Nov 8 2009 6:14 am
Subject: Re: good to have typedef?

I'm curious... what system doesn't "have" a uint32_t? I work also on
small 8bit micros (in C, but that's not really the issue here), and if I
really need it, I can use a uint32_t. It's not a native word size on
those systems, but the compiler couldn't care less about that. (Well,
the compiler writer of course does, and I do, too, where performance and
resources are an issue -- but the system "has it".)

Gerhard


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gerhard Fiedler  
View profile  
 More options Nov 8, 6:18 am
Newsgroups: comp.lang.c++
From: Gerhard Fiedler <geli...@gmail.com>
Date: Sat, 7 Nov 2009 16:48:42 -0200
Local: Sun, Nov 8 2009 6:18 am
Subject: Re: good to have typedef?

Nick Keighley wrote:
> Lovely bug:-

>    Station_id read_station_id (FILE *in)
>    {
>       Station_id station_id;
>       fscanf (in, "%d", &station_id);
>       return station_id;
>    }

> Station_id was a short.

You should get a compiler or linter that checks for such things -- or
use C++ streams in the first place :)

I found a few of these while porting a project from VC++ to gcc. gcc has
an option to check printf-type format strings.

Gerhard


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bo Persson  
View profile  
 More options Nov 8, 8:13 am
Newsgroups: comp.lang.c++
From: "Bo Persson" <b...@gmb.dk>
Date: Sat, 7 Nov 2009 21:43:02 +0100
Local: Sun, Nov 8 2009 8:13 am
Subject: Re: good to have typedef?

Systems like these, that are based on 36-bit hardware

http://www.unisys.com/clearpath

Requiring them to have a uint32_t would be REALLY expensive. To top it
off, these machines also have 9-bit bytes, one's complement
arithmetic, and 72-bit non-IEEE floating point.  :-)

Unlike Java, C++ could actually be implemented.

Bo Persson


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Kanze  
View profile  
 More options Nov 9, 11:37 am
Newsgroups: comp.lang.c++
From: James Kanze <james.ka...@gmail.com>
Date: Sun, 8 Nov 2009 16:07:28 -0800 (PST)
Local: Mon, Nov 9 2009 11:37 am
Subject: Re: good to have typedef?
On Nov 7, 7:44 pm, Gerhard Fiedler <geli...@gmail.com> wrote:

Neither of the Unisys mainframe architectures: one's 36 bit ones
complement, the other 48 bit signed magnitude (with 8 bits
reserved).

> I work also on small 8bit micros (in C, but that's not really
> the issue here), and if I really need it, I can use a
> uint32_t.  It's not a native word size on those systems, but
> the compiler couldn't care less about that. (Well, the
> compiler writer of course does, and I do, too, where
> performance and resources are an issue -- but the system "has
> it".)

The compiler has to provide 32 bit arithmetic somehow, and if
the machine is 8 bits, using 32 bits for long, rather than more,
is the preferred solution.  The problems are more with larger
machines, where the machine word size is 36 or 48 bits (or in
the past, 60 bits)---at one time, 36 bits was quite common.

--
James Kanze


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google