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?
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 '17 at 7:38
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 '17 at 9:17lsp-mode
withclangd
language server. So far no success.clangd
should "know everything". Anyone have an idea how to make it work there? – Oliver Schönrock Dec 20 '19 at 13:43