What is “…” in switch-case in C code

This is a gcc extension called case ranges, this is how it is explained in the document:

You can specify a range of consecutive values in a single case label, like this:

case low ... high:

You can find a complete list of gcc extensions here. It seems like clang also supports this to try and stay compatible with gcc. Using the -pedantic flag in either gcc or clang will warn you that this is non-standard, for example:

warning: range expressions in switch statements are non-standard [-Wpedantic]

It is interesting to note that Linux kernel uses a lot of gcc extensions one of the extensions not covered in the article is statement expressions.

Leave a Comment