C语言源代码中,行结尾有反斜杠,这些反斜杠有什么用?

例如以下这段代码:

#define PHPMY_UNBUFFERED_QUERY_CHECK() \
{ \
if (mysql->active_result_id) { \
do { \
int type; \
MYSQL_RES *mysql_result; \
\
mysql_result = (MYSQL_RES *) zend_list_find(mysql->active_result_id, &type); \
if (mysql_result && type==le_result) { \
if (!mysql_eof(mysql_result)) { \
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Function called without first fetching all rows from a previous unbuffered query"); \
while (mysql_fetch_row(mysql_result)); \
} \
zend_list_delete(mysql->active_result_id); \
mysql->active_result_id = 0; \
} \
} while(0); \
} \
}
行末的“\”有什么特殊意义?

第1个回答  推荐于2018-08-24
反斜杠起到换行作用,用于宏定义和字符串换行。其中宏定义中使用居多。
如果一行代码有很多元素,导致太长影响阅读,可以通过在结尾加\的方式,实现换行,编译时会忽略\及其后的换行符,当做一行处理。
在宏定义中,要换行必须使用\结尾。
在字符串常量中,可以使用\结尾,如
"this \
is \
for\
testing"
和"this is for testing"是相同的,但是对于字符串写成
"this "
"is "
" for"
"testing"
效果是相同的,而且更美观。
另外,在普通的语句中,也可以通过\实现换行,不过这时没有\也是一样的效果。
比如
printf("this is for test %d %d %d\n",\
test_output_a,\
test_output_b,\
test_output_c);

printf("this is for test %d %d %d\n",
test_output_a,
test_output_b,
test_output_c);
是没有区别的,所以这时一般不会使用\。本回答被网友采纳
第2个回答  2013-09-29
注释。。。。