home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.std.c++:1981 comp.lang.c++:18760
- Path: sparky!uunet!racerx!rodb
- From: rodb@racerx.bridge.COM (Rod Burman)
- Newsgroups: comp.std.c++,comp.lang.c++
- Subject: Extra COntant definitions
- Summary: Suggestions for Extending C++ types
- Message-ID: <1224@racerx.bridge.COM>
- Date: 6 Jan 93 17:30:44 GMT
- Followup-To: comp.std.c++
- Organization: Bridge Information Systems
- Lines: 49
-
- It has just occured to me that since C++ is a strongly typed language
- it should provide intrinsic support for constants of all intrinsic types
- that is currently we have:
-
- 1 // int
- 1U // unsigned int
- 1L // long
- 1UL // unsigned long
- '\1' // unsigned char -- it is unsigned since only
- // octal and hex bit patterns are allowed and
- // by default they are unsigned -- this may be
- // shakey logic, it may be implimentation dependent
- // on whether char is signed/unsigned, I admit
- '\1'L // wide unsigned char -- see above comment
- "\1" // unsigned char[]
- "\1"L // unsigned wide char -- w_chart is scheduled to
- // be an intrinsic type in ANSI/ISO C++
-
- This as I see it leaves room for:
-
- 1S // short
- 1US // unsigned short
- 1I // int -- this may not be really neccessary!
- 1UI // unsigned int
- '\1'S // signed char -- see I'm following the spirit of C
- // and confusing programmers nicely by using S for both
- // short and signed!
- '\1'U // unsigned char
- '\1'SL // signed wide char
- '\1'UL // unsigned wide char
- "\1"S // signed char[]
- "\1"U // unsigned char[]
- "\1"SL // signed wide char[]
- "\1"UL // unsigned wide cahr[]
-
- Ofcourse you can always have:
-
- (short) 1; // etc
-
- and this may be more portable since you can then have:
-
- (int16) 1; // etc
-
- where you typedef int16, etc to the correct type in some header somewhere which takes
- care of compiler/OS/machine dependecies, but shouldn't you be able to do the other way
- if you want? (Can any one send me the appropriate #define macro to convert 1INT32; to
- 1L or 1 depending on wether long is 32 or 64 bits?)
- Well just a though for the standards committee after all it shouldn't break any
- existing code should it?
-