Re: completed my Varaint class.
From: Richard Heathfield (invalid_at_address.co.uk.invalid)
Date: 01/26/04
- Next message: cald: "Derived Class from a base class..."
- Previous message: David Jones: "open file with arbitrary name"
- In reply to: Jumbo: "Re: completed my Varaint class."
- Next in thread: Jumbo: "Re: completed my Varaint class."
- Reply: Jumbo: "Re: completed my Varaint class."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 26 Jan 2004 20:14:20 +0000
Jumbo wrote:
>
> "Richard Heathfield" <invalid@address.co.uk.invalid> wrote in message
> news:40152574@news2.power.net.uk...
>> Attila Feher wrote:
>>
>> >> "Ian Woods" <newspub2@wuggyNOCAPS.org> wrote in message
>> >> Your telling me MSVC++ is non conforming , who you think I'm gonna
>> >> believe, you or Microsoft?
>> >
>> > Believe Microsoft.
>>
>> Not only did Ian not say that (which you have already worked out, of
>> course), but Ian didn't even say that MSVC++ was non-conforming. He said
>> that Jumbo's code is non-conforming (which is true).
>>
>> <snip>
>>
>> --
>
> Mike said that the definition of size_t can only be defined in an included
> header with the #include directive.
Actually, he said "If your code uses 'size_t' without #including a standard
header which is defined to declare it, your code is not compliant."
> What I am asking is why and who says so?
The exact type of size_t can vary from one implementation to another. The
Standard says relatively little about it, but it does say that size_t is an
unsigned integral type, and we can deduce from other parts of the Standard
that it must have at least 15 value bits (in C90, or 16 in C99) but can
have more. If you adopt the very simple procedure of getting your size_t
definition from a standard header, then your code will be portable (in that
respect, at least) from one implementation to another. If you roll your own
definition, then you no longer have that guarantee. That's what Mike means
by your code not being "compliant".
As for "who says so?", well, ISO says so. If you don't give a jot whether
your code works anywhere except MSVC++, then that's entirely up to you, but
on /this/ channel we don't assume people are using MSVC++ when giving them
C or C++ advice.
> And also what I am saying is what difference does it make it it is defined
> in an included header than if it were defined at the top of the page?
Your definition:
#define unsigned integer size_t
wouldn't actually work anyway, since it doesn't define a size_t type at all.
> I don't know if yous are agreeing with this or not.
> Are you saying that the standards state this , and if so why?
The Standard exists to make it possible to write C (or, in the case of C++,
C++!) programs that can work correctly on disparate compilers. If you
define your own size_t type, then you cost yourself portability with no
apparent gain in mind. You don't even save typing, since even a marginally
more correct (but still not portable!) definition of size_t, such as:
typedef unsigned long size_t;
takes more characters than
#include <stddef.h>
> What is the point in this?
I have no idea what point you are trying to make. It appears you would
rather spend more time and effort writing non-portable code than I would
spend writing the portable equivalent.
-- Richard Heathfield : binary@eton.powernet.co.uk "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999. C FAQ: http://www.eskimo.com/~scs/C-faq/top.html K&R answers, C books, etc: http://users.powernet.co.uk/eton
- Next message: cald: "Derived Class from a base class..."
- Previous message: David Jones: "open file with arbitrary name"
- In reply to: Jumbo: "Re: completed my Varaint class."
- Next in thread: Jumbo: "Re: completed my Varaint class."
- Reply: Jumbo: "Re: completed my Varaint class."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|