1

I read that it is difficult to find out if an element is in an enumeration. So what would be the best way ?

For example, the following code comes from the Linux kernel 2.6.32:

enum v4l2_colorfx { V4L2_COLORFX_NONE = 0, V4L2_COLORFX_BW = 1, V4L2_COLORFX_SEPIA = 2, }; 

And this one from the 2.6.38 version:

enum v4l2_colorfx { V4L2_COLORFX_NONE = 0, V4L2_COLORFX_BW = 1, V4L2_COLORFX_SEPIA = 2, V4L2_COLORFX_NEGATIVE = 3, V4L2_COLORFX_EMBOSS = 4, V4L2_COLORFX_SKETCH = 5, V4L2_COLORFX_SKY_BLUE = 6, V4L2_COLORFX_GRASS_GREEN = 7, V4L2_COLORFX_SKIN_WHITEN = 8, V4L2_COLORFX_VIVID = 9, }; 

How would you check if V4L2_COLORFX_NEGATIVE is defined ? Would #ifndef V4L2_COLORFX_NEGATIVE be okay ?

2 Answers 2

3

You would have to look at a compiler macro in the wider context (for example the version of linux, I don't know what's available) or some other piece of information at compile time. ifndef is for checking if compiler macros are defined, not symbols in code.

Sign up to request clarification or add additional context in comments.

Comments

1

Check the version of linux in /usr/include/linux/version.h ( you need to install kernel headers though )

it contains something like :

#define LINUX_VERSION_CODE 132640 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 

So you can use this :

#if LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 38 ) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.