简体   繁体   中英

Can we have a function without a name in C?

I was digging SnoopSnitch 's source code when I found in one of it's libraries this line, written in C :

(_s, m);

_s and m are both structures so what can it be ?

PS: Check the end of this file to see the actual source code.

C hasn't "methods" at all, it has functions.

In any event, the code you present is not a function call, it is an expression statement. The parentheses serve their precedence-overriding grouping function, albeit unnecessarily, and the comma is the comma operator, which evaluates both operands, and has as its result the value of its second operand.

Inasmuch as the result is unused and the comma's operands are simple variable names, the statement overall has no side effects. The only purpose I can think of is the one @chux suggested in comments: to provide a statement where you can insert a breakpoint for debugging, and especially for examining the values at that point of the two variables involved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM