What is [in] and [out]?

advertisements

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) {

}


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.