I was reading through this Advanced Linux Programming tutorial when I encountered a problem. I was trying to eject the CD-ROM drive using this code:
int fd = open(path_to_cdrom, O_RDONLY); // Eject the CD-ROM drive ioctl(fd, CDROMEJECT); close(fd);
Then I try to compile this code and get the following output:
In file included from /usr/include/linux/cdrom.h:14, from new.c:2: /usr/include/asm/byteorder.h: In function ‘___arch__swab32’: /usr/include/asm/byteorder.h:19: error: expected ‘)’ before ‘:’ token /usr/include/asm/byteorder.h: In function ‘___arch__swab64’: /usr/include/asm/byteorder.h:43: error: expected ‘)’ before ‘:’ token
So what am I doing wrong?
Advertisement
Answer
The error message you’re seeing looks like something is wrong in your #include lines, not with the code you posted. I tried compiling http://www.advancedlinuxprogramming.com/listings/chapter-6/cdrom-eject.c and it compiles just fine.