It has been difficult to see immediately the types of variables in C++ codes because they are defined using 'auto', 'template' and 'decltype'.
If you use IDE, you can detect the type after the compilation by being a cursor on the variable.
My question is, does an emacs package exist to achieve such a function?

  • I think your best bet will be irony-mode as suggested by @GuillaumePapin. With Function-Args disabled I still get mini-buffer descriptions of auto type variables - which were of type auto before compilation. So no, you cannot get this behaviour alone with Function-Args - my apologies. Will my check .emacs.d and get back to you.
    – nyameko
    Feb 28, 2017 at 9:17
  • Thank you for sincere coping. I decided to use irony-mode as suggested by @GuillaumePapin. However, as he said, irony-mode is not enough to display the types of any variables in C++ codes. I think the demand of more powerful packages will be increasing. Feb 28, 2017 at 10:59
  • I have looking for an option in lsp-mode with clangd language server. So far no success. clangd should "know everything". Anyone have an idea how to make it work there? Dec 20, 2019 at 13:43

1 Answer 1


With irony-mode, you can use M-x irony-get-type RET. This probably won't work for everything but it worked for the following snippet:

int main()
   auto var = 1.0;
   return var;

Having the cursor on any of the two var, and calling M-x irony-get-type RET, returns: double in the minibuffer.

  • Helpful answer. Just to make this complete, I would add a key binding in my .emacs to get the type result without a need to type in the command each time. For example: (global-set-key [C-f1] 'irony-get-type)
    – ElazarR
    Mar 1, 2017 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.