在case语句标准C / C ++省略号 [英] Are Elipses in case statements standard C/C++

查看:219
本文介绍了在case语句标准C / C ++省略号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在浏览一些code在Linux内核和我遇到的声明是像为'0'...'9':

I was browsing some code in the linux kernel and I came across the statements like case '0' ... '9':

要尝试了这一点,我创建下面的测试程序。

To try this out I created the test program below.

#include <iostream>

int main()
{
    const int k = 15;

    switch (k)
    {
    case 0 ... 10:
        std::cout << "k is less than 10" << std::endl;
        break;
    case 11 ... 100:
        std::cout << "k is between 11 and 100" << std::endl;
        break;
    default:    
        std::cout << "k greater than 100" << std::endl;
        break;
    }
}   

上述程序并编译,虽然我从来没有的情况下,语句结构遇到的省略号之前。这是标准的C和C ++或者这是一个GNU特定扩展的语言?

The program above does compile although I have never come across the elipses in case statement construct before. Is this standard C and C++ or is this a GNU specific extension to the language?

推荐答案

这是的 GNU C编译器的受案范围扩展程序,它不是标准C或C ++。

That is the case range extension of the GNU C compiler, it is not standard C or C++.

这篇关于在case语句标准C / C ++省略号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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