China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 22:06
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » It looks like an illegal statement, but it can actually be compiled and run successfully, and the result is correct! View 1,567 Replies 3
Original Poster Posted 2006-07-28 21:39 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
23-year member
UID 7105
Gender Male
Status Offline
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)!!!
Floor 2 Posted 2006-07-29 04:01 ·  中国 上海 虹口区 电信
高级用户
★★
Credits 653
Posts 252
Joined 2006-04-16 19:48
20-year member
UID 53939
Status Offline
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?

Floor 3 Posted 2006-07-29 14:47 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 4 Posted 2006-07-29 22:51 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
23-year member
UID 7105
Gender Male
Status Offline
Yes, comma expression
Reviewed
Forum Jump: