Bush
Bush

Reputation: 2533

Two enum definitions of the same variable

I've noticed some code in the linux kernel with the following:

In the file s3c-dma-pl330.h there is a definition:

enum dma_ch {
...
};

and at the end of that file there is: #include <plat/dma.h> In that file (dma.h) there is: enum dma_ch; No extern is written, can you tell what is actually happens?

Does dma_ch in dma.h is the same as in s3c-dma-pl330.h? Why isn't there the extern specifier?

Upvotes: 0

Views: 43

Answers (1)

Bill Lynch
Bill Lynch

Reputation: 81926

enum dma_ch; is a forward declaration of the enumeration.

We use extern when we want to refer to an instance of an object that is found in (possibly) some other translation unit. dma_ch is not an object, it is a type.

Upvotes: 4

Related Questions