ALT Linux Community general discussions
 help / color / mirror / Atom feed
* [Comm] [JT] C function parameters order
@ 2005-08-18  8:36 Vitaly Ostanin
  2005-08-18  8:53 ` Andrew Borodin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Vitaly Ostanin @ 2005-08-18  8:36 UTC (permalink / raw)
  To: ALT Linux Community

[-- Attachment #1: Type: text/plain, Size: 536 bytes --]

Здравствуйте.

Тут прислали прикол:
#include <stdio.h>
void test(int a, int b, int c, int d)
{
printf("a=%d, b=%d, c=%d, d=%d\n", a ,b, c, d);
}
void main(void)
{
int c = 1;
test(++c, ++c, ++c, ++c);
test(c++, c++, c++, c++);
printf("\nc=%d\n", c);
}

gcc-3.4.4 и борландовский turbo C 2.0.1 говорят:
a=5, b=4, c=3, d=2
a=8, b=7, c=6, d=5

c=9

А MS visual C 6.0 говорит:
a=5, b=4, c=3, d=2
a=5, b=5, c=5, d=5

c=9

Кто из них не прав?

-- 
Regards, Vyt
mailto:  vyt@vzljot.ru
JID:     vyt@vzljot.ru


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Comm] [JT] C function parameters order
  2005-08-18  8:36 [Comm] [JT] C function parameters order Vitaly Ostanin
@ 2005-08-18  8:53 ` Andrew Borodin
  2005-08-18  9:22   ` [Comm] " Vitaly Ostanin
  2005-08-18  8:57 ` [Comm] " Alexey V. Novikov
  2005-08-18  8:59 ` Damir Shayhutdinov
  2 siblings, 1 reply; 5+ messages in thread
From: Andrew Borodin @ 2005-08-18  8:53 UTC (permalink / raw)
  To: ALT Linux Community

On Thu, Aug 18, 2005 at 12:36:35PM +0400, Vitaly Ostanin wrote:

> Кто из них не прав?

Большой тред по такому же вопросу:

http://rsdn.ru/Forum/Message.aspx?mid=94130

-- 

С уважением,
А. Бородин.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Comm] [JT] C function parameters order
  2005-08-18  8:36 [Comm] [JT] C function parameters order Vitaly Ostanin
  2005-08-18  8:53 ` Andrew Borodin
@ 2005-08-18  8:57 ` Alexey V. Novikov
  2005-08-18  8:59 ` Damir Shayhutdinov
  2 siblings, 0 replies; 5+ messages in thread
From: Alexey V. Novikov @ 2005-08-18  8:57 UTC (permalink / raw)
  To: ALT Linux Community

18.08.2005 12:36, Vitaly Ostanin пишет:
> Здравствуйте.
> 
> Тут прислали прикол:
> #include <stdio.h>
> void test(int a, int b, int c, int d)
> {
> printf("a=%d, b=%d, c=%d, d=%d\n", a ,b, c, d);
> }
> void main(void)
> {
> int c = 1;
> test(++c, ++c, ++c, ++c);
> test(c++, c++, c++, c++);
> printf("\nc=%d\n", c);
> }
> 
> gcc-3.4.4 и борландовский turbo C 2.0.1 говорят:
> a=5, b=4, c=3, d=2
> a=8, b=7, c=6, d=5
> 
> c=9
> 
> А MS visual C 6.0 говорит:
> a=5, b=4, c=3, d=2
> a=5, b=5, c=5, d=5
> 
> c=9
> 
> Кто из них не прав?

А если вот так (MinGW GCC 3.3.1 (mingw special 20030804-1))
gcc -o main.exe -O3 main.c, то имеем:

a=2, b=3, c=4, d=5
a=5, b=6, c=7, d=8

c=9

:)

-- 
WBR, Alexey V. Novikov


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Comm] [JT] C function parameters order
  2005-08-18  8:36 [Comm] [JT] C function parameters order Vitaly Ostanin
  2005-08-18  8:53 ` Andrew Borodin
  2005-08-18  8:57 ` [Comm] " Alexey V. Novikov
@ 2005-08-18  8:59 ` Damir Shayhutdinov
  2 siblings, 0 replies; 5+ messages in thread
From: Damir Shayhutdinov @ 2005-08-18  8:59 UTC (permalink / raw)
  To: ALT Linux Community

Vitaly Ostanin пишет:

>Здравствуйте.
>
>Тут прислали прикол:
>#include <stdio.h>
>void test(int a, int b, int c, int d)
>{
>printf("a=%d, b=%d, c=%d, d=%d\n", a ,b, c, d);
>}
>void main(void)
>{
>int c = 1;
>test(++c, ++c, ++c, ++c);
>test(c++, c++, c++, c++);
>printf("\nc=%d\n", c);
>}
>
>gcc-3.4.4 и борландовский turbo C 2.0.1 говорят:
>a=5, b=4, c=3, d=2
>a=8, b=7, c=6, d=5
>
>c=9
>
>А MS visual C 6.0 говорит:
>a=5, b=4, c=3, d=2
>a=5, b=5, c=5, d=5
>
>c=9
>
>Кто из них не прав?
>  
>
ЕМНИП, стандартом поведение не определено. Так что неправ только 
программист.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Comm] Re: [JT] C function parameters order
  2005-08-18  8:53 ` Andrew Borodin
@ 2005-08-18  9:22   ` Vitaly Ostanin
  0 siblings, 0 replies; 5+ messages in thread
From: Vitaly Ostanin @ 2005-08-18  9:22 UTC (permalink / raw)
  To: ALT Linux Community

[-- Attachment #1: Type: text/plain, Size: 304 bytes --]

Andrew Borodin пишет:
> On Thu, Aug 18, 2005 at 12:36:35PM +0400, Vitaly Ostanin wrote:
> 
> 
>>Кто из них не прав?
> 
> Большой тред по такому же вопросу:
> 
> http://rsdn.ru/Forum/Message.aspx?mid=94130

Спасибо, понял.

-- 
Regards, Vyt
mailto:  vyt@vzljot.ru
JID:     vyt@vzljot.ru


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-08-18  9:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-18  8:36 [Comm] [JT] C function parameters order Vitaly Ostanin
2005-08-18  8:53 ` Andrew Borodin
2005-08-18  9:22   ` [Comm] " Vitaly Ostanin
2005-08-18  8:57 ` [Comm] " Alexey V. Novikov
2005-08-18  8:59 ` Damir Shayhutdinov

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git