C源文件中的反斜杠 [英] Backslash in c source file

查看:98
本文介绍了C源文件中的反斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在不同的行上遵循相同的代码:

I have follow code same as it is on different lines:

frame_rate = (float)
                ( ( ( frames * media_timescale) + \   //WHY???
                    ( media_duration >> 1 ) ) /
                 media_duration);

我不了解源文件中的反斜杠在做什么? 同样,要计算帧速率,我们可以按照以下步骤操作:

I am not understanding what is backslash doing in source file ? Also to calculate the frame rate simply we can do as follow:

frame_rate = (float) ( (  frames * media_timescale) / media_duration);

是否有写第一类代码的特定意图?

Is there any specific intention to write first type of code?

推荐答案

这是行继续转义.这意味着编译器会将下一行视为当前行的一部分.

It's a line-continuation escape. It means the compiler will consider the next line as a part of the current line.

它使您在实践中显示的代码成为现实

It makes the code you show in practice being

frame_rate = (float)
                ( ( ( frames * media_timescale) + ( media_duration >> 1 ) ) /
                 media_duration);

在这种情况下,它并没有真正的需要,除了作者可能遵循的一些样式指南是必需的.

There's no real need for it in this case though, except as maybe some style-guide followed by the author had it as a requirement.

需要行连续来定义多行"宏,并且也常用于长字符串.但是除了那些地方,它没有任何实际用途.

Line continuation is needed to define "multi-line" macros, and are also often used for long strings. But besides those places, it serves no real purpose.

这篇关于C源文件中的反斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆