2

I was going through the latest code in the Linux kernel, when I found a switch written differently.

kernel/drivers/net/ethernet/intel/e1000/e1000_main.c Line number 3524

As per my C knowledge, switch/case needs to be written as

case e1000_undefined: // enum value as 0
case e1000_82542_rev2_0: // enum value as 1
case e1000_82542_rev2_1: // enum value as 2
         // code

But in kernel code I found it like this:

case e1000_undefined ... e1000_82542_rev2_1:
         // code

Is this C18 coding style for C?

Can someone point me a resource (book/GNU man pages) to understand more about C18?

0x5C91
  • 3,360
  • 3
  • 31
  • 46
Rohit
  • 98
  • 4
  • What makes you think it's C18? – Joachim Sauer Jan 22 '20 at 07:08
  • other duplicates: [what does this syntax of switch case mean in C?](https://stackoverflow.com/q/17699746/995714), [Are triple dots inside a case (case '0' … '9':) valid C language switch syntax?](https://stackoverflow.com/q/7043788/995714), [Are Elipses in case statements standard C/C++](https://stackoverflow.com/q/5924681/995714), [Choosing enum element using “…” (duplicate)](https://stackoverflow.com/q/37318196/995714) – phuclv Jan 22 '20 at 07:20
  • 2
    The "c18" tag is for "MPLAB C Compiler for PIC18 MCUs" , is that what you are asking about? (Not to be confused with ISO/IEC 9899:2018) – M.M Jan 22 '20 at 07:26

1 Answers1

4

Case ranges are a GCC extension for C.

the busybee
  • 10,755
  • 3
  • 13
  • 30
  • Thanks, then what is C18 ? where can I get to know more ? I want to understand difference between C18 and old C (C98/C99) – Rohit Jan 23 '20 at 05:33
  • You may start with [C's wikipedia page](https://en.wikipedia.org/wiki/C_(programming_language)). – the busybee Jan 23 '20 at 06:41
  • @Rohit These will also help: https://en.cppreference.com/w/c (see tiny links: " C89, C95, C99, C11, C17, C23") and https://en.cppreference.com/w/c/language/history – kevinarpe Oct 26 '22 at 14:20