user1873073
user1873073

Reputation: 3670

What is [in] and [out]?

I came across this code but I have not seen [in] or [out] before. What are they?

HRESULT QueryInterface([in] REFIID riid, [out] void **ppvObject) {

}

Upvotes: 2

Views: 213

Answers (3)

kotlomoy
kotlomoy

Reputation: 1430

These are directional IDL attributes. They indicate the direction that data is being passed.

Upvotes: 4

mah
mah

Reputation: 39807

As provided in your question, the code probably won't compile. That being said, though not common you might come across code such as:

HRESULT QueryInterface(IN REFIID riid, OUT void **ppvObject)

which compiles because somewhere IN and OUT are #define'd (to be empty). This is sometimes done with pointers to indicate if the parameters are input (read only), or output (written to), or BOTH. This indication is for the reader's benefit.

Upvotes: 3

KevinDTimm
KevinDTimm

Reputation: 14376

it's an indication of a value that's being sent [in] to a function or, in the case of [out] it's being changed and so is an [out]put

Upvotes: 2

Related Questions