Re: is order urgent doubt



new to c <non@xxxxxxxxxxxx> writes:
Bartc wrote:
"new to c" <non@xxxxxxxxxxxx> wrote in message
news:6468955.gypaU67uLZ@xxxxxxxxxxxxxxxx

I write big international program and need double integer. Why size is
different when other order?

Try: long long int

If you're lucky, this will have size 8.


Problem equal.

You mean "the same problem".

int i;
i = sizeof(long long int);
printf("%i", i);

i = sizeof(long int long);
printf("%i", i);

i = sizeof(int long long);
printf("%i", i);

First code warn nothing and print 8.

Second code warn "multiple use of 'long'" and print 4.

Third code warm "multiple use of 'longlong'" and print 8.

Why is different number? Is order urgent?

You mean "important" or "significant", not "urgent".

Assuming the code you posted is the code you actually compiled and
ran, it appears that your compiler is buggy. What compiler are you
using?

Please post a small complete program that exhibits the problem.
Copy-and-paste the entire exact program; don't re-type it or summarize
it. Show us the compiler's warnings and the program's output
(copy-and-paste them as well).

Change each "%i" to "%i\n" (or "%d\n", which is equivalent but more
common).

Not all compilers support "long long", but most do (the feature was
added in C99, but a lot of pre-C99 compilers support it as an
extension).

All three chunks of code are exactly equivalent. For an integer type,
the order of the keywords is not significant; all of "long long int",
"long int long", and "int long long" mean exactly the same thing. If
your compiler is treating them differently, then there's a bug in your
compiler. (I think we've already told you this.)

As a matter of programming style, messing around with the order of the
keywords isn't a good idea. A properly working compiler won't care,
but using an order other than the usual one will just make your code
(slightly) harder to read, with no real benefit. (It's been argued
that using, for example, "long unsigned" rather than "unsigned long"
helps to remind you to use "%lu" rather than "%ul" for printf; I don't
find that argument convincing.)

Also, if you use the more common orderings, it's likely you can avoid
triggering your compiler's bugs (though I'd recommend finding a
compiler that works properly).

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: pointers?
    ... int a; ... Well, not a bug IMO, but yes, that's what I'm talking about. ... Foo is called with delta as parameter, ... compiler "optimizes" b away, therefore the compiler has a bug. ...
    (comp.lang.forth)
  • Re: It Pays to Enrich Your C Skills
    ... Check if you can score a perfect 10 (without using a compiler). ... int main{ ... struct bitfield { ... out if it is a negative integer constant or a constant expression ...
    (comp.lang.c.moderated)
  • OT: Re: Perl Peeves
    ... I see the result of a test being used as an int. ... the compiler just assumed you knew what you were doing ... introduced to the language later, so void * was unheard of in most code. ... This didn't mean bool was special, declaring it just signaled to the ...
    (comp.lang.perl.misc)
  • Re: OT: Re: Perl Peeves
    ... when I see the result of a test being used as an int. ... compiler just assumed you knew what you were doing and would ... This didn't mean bool was special, declaring it just signaled to the ... What "normalization of bool results is built into the compiler"? ...
    (comp.lang.perl.misc)
  • Re: [CodeGallery] MFC MD5 Calculator
    ... Then when they added types, internally, the compiler still thought they were int values, ... ANSI standard began to emerge that the language design ...
    (microsoft.public.vc.mfc)