Which compiler version are you using? I have some notes that indicate that ifort has had issues returning C_PTR's from functions in the 12.0 era. (I don't have access to recent compilers on linux to see what the situation is today.) Your code examples for the function in the OP look ok to me, bar what I presume are transcription errors. In the subroutine makeDerivedType argument case I'd be inclined to declare the argument as void** on the C side.
Which compiler version are you using? I have some notes that indicate that ifort has had issues returning C_PTR's from functions in the 12.0 era. (I don't have access to recent compilers on linux to see what the situation is today.) Your code examples for the function in the OP look ok to me, bar what I presume are transcription errors. In the subroutine makeDerivedType argument case I'd be inclined to declare the argument as void** on the C side.