What if the only variable type was int?

Pages: 12
| is Pipe?

@chrisname: I said very similar to C++, so that means there is a guarantee of there being at least 8 bits to a byte. 'At least' is good enough for me :)
I was referring to {this is a possible option|and this is another}.

I said very similar to C++, so that means there is a guarantee of there being at least 8 bits to a byte.

But C++ doesn't guarantee that.
The fundamental storage unit in the C++ memory model is the byte. A byte is at least large enough to contain any member of the basic execution character set and is composed of a contiguous sequence of bits, the number of which is implementation-defined.
Last edited on
Standard wrote:
A byte is at least large enough to contain any member of the basic execution character set
How large does it have to be to contain any member of the basic execution character set?
Last edited on
No larger smaller than 7 bits, I believe.
The basic execution character set [shall] contain all the members of the basic source character set, plus control characters representing alert, backspace, and carriage return, plus a null character (respectively, null wide character), whose representation has all zero bits.
Last edited on
I'm not sure what "the basic execution character set" means but I would think 7 bits was the minimum, since that's how many bits you need to store any character from the standard ASCII set.
That char is at least 8 bits follows from section 18.3.3.2 of the C++ standard.
closed account (3hM2Nwbp)
[rant against several popular libraries]

int8/int32/float64 etc. would be easier on the eyes.


Anything would be easier on the eyes than

1
2
3
4
MY_LIBRARY_INT_8_T
MY_LIBRARY_INT_16_T
MY_LIBRARY_INT_X_T
...


I still cannot fathom why library developers continue to create obscure, redundant typedefs for the basic integer types.

[/rant against several popular libraries]
I didn't pick up on what was so different than C++. I use uint64_t's and the like all of the time, as do many organizations. A pointer, a char, whatever all boil down to just numbers, do they not?
@Luc:
It's rather simple, actually. If the developers for any reason need to change the types of a large number of internal variables, then by using typedefs of simple variables for all of them, then the process becomes that much easier.

-Albatross
I don't think he was asking why they used typedefs, I think he was asking why they used obscure, redundant typedefs.

As for an answer, well, I don't use libraries with obscure or redundant typedefs - I use ones with simple ones like: lw_i32 (32bit int)

If the developers for any reason need to change the types of a large number of internal variables, then by using typedefs of simple variables for all of them, then the process becomes that much easier.


If you are calling a type MY_LIBRARY_INT_8_T you very likely aren't going to change it's definition, and if you do the result would probably be that the name is a lie.
Last edited on
@hanst99
In that specific example, yes. I was speaking more generally.

Now, typedefs that specify a bit too explicitly what the underlying variable type is are... redundant, and I fully agree. It's pointless.

-Albatross
Topic archived. No new replies allowed.
Pages: 12