|
![](/i/fill.gif) |
On 17/04/2012 03:26 PM, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>> Now /that/ actually makes sense. Where are these typedefs located? Do
>> you have to include them specifically, or...?
>
> IIRC they are in<cstdint>.
A quick Google search indicates that cstdint defines std::int8_t,
std::int16_t and so on, plus uint versions (presumably unsigned). It
also defines std::int_fast8_t and friends, std::int_least8_t and so on,
a std::intmax_t and a std::intintptr_t.
>> I had hoped for maybe a compile-time warning. I haven't actually tried
>> it to see if I get one though...
>
> Some compilers will give you a warning if they think that a variable
> is being used uninitialized, but given that the general problem of
> determining that is unsolvable, it's not fool-proof.
>
> There are some tools (such as valgrind) that will tell you at runtime.
I may yet end up having to investigate valgrind. It seems it's the only
reliable way to discover if your code leaks memory...
>> Aren't expressions guaranteed to execute left-to-right?
>
> Expressions with side-effects can happen in any order. The compiler is
> free to optimize expressions in any way it likes (as long as the result
> is always the same if the expression had no multiple side-effects on the
> same variable).
I see. So that's why programs tend to break if you turn the optimisation
settings up too high?
>> But that's just it. All C programmers always code in this kind of style.
>> It's part of what makes C so terrifying to try to read.
>
> C programmers (at least competent ones) do not have multiple side-effects
> on the same variable inside the same expression. They may have multiple
> side-effects on *different* variables, which is ok. For example:
>
> while(*dest++ = *src++) {}
>
> There are two side-effects there, but they are operating on different
> variables, so there's no ambiguity.
It still makes my head hurt. >_<
> What do you think this will print?
>
> bool b = true;
> std::cout<< b<< std::endl;
Well, I guess now that C++ has /names/ for true and false, I don't have
to worry about it.
Is bool still regarded as an alias to an integer type? Or does it really
get treated as a separate, distinct type?
Post a reply to this message
|
![](/i/fill.gif) |