中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-01 23:13
48,037 topics / 350,122 posts / today 2 new / 48,250 members
DOS开发编程 & 发展交流 (开发室) » It looks like an illegal statement, but it can actually be compiled and run successfully, and the result is correct!
Printable Version  1,568 / 3
Floor1 GOTOmsdos Posted 2006-07-28 21:39
铂金会员 Posts 1,827 Credits 5,154
In the source code of GZIP in GNU, when compiled on TC2, it passes.

#define FLUSH_BLOCK(eof) \
flush_block(block_start >= 0L ? (char*)&window[(unsigned)block_start] : \
(char*)NULL, (long)strstart - block_start, (eof))

With the above macro definition, there is the following statement that feels violating regulations later!
if (flush) FLUSH_BLOCK(0), block_start = strstart;

Attention!!! The above "comma" (not semicolon)!!!
Floor2 asbai Posted 2006-07-29 04:01
高级用户 Posts 252 Credits 653
What's wrong with commas? In C/C++ grammar, expressions separated by commas are evaluated from left to right, and the value of the entire expression is the value of the rightmost sub-expression.

Are function calls and assignments both legal expressions?

Floor3 electronixtar Posted 2006-07-29 14:47
铂金会员 Posts 2,672 Credits 7,493
Floor4 GOTOmsdos Posted 2006-07-29 22:51
铂金会员 Posts 1,827 Credits 5,154
Yes, comma expression
Reviewed
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023