[Development] The age-old T* foo vs. T *foo

Vasily Pupkin shkodindanil.letmework at gmail.com
Thu Oct 17 22:25:10 CEST 2019


Declaring variables

   - Declare each variable on a separate line

https://wiki.qt.io/Qt_Coding_Style

Multiple declarations on the same line is not a valid argument as long as
they are forbidden.

Asterisk position, imho, should be based on the mental model.

X* x - is an identifier that names a variable. It's type is a pointer to X
and it's size btw is the same as any other pointer to object.

I have just chimed in to ask about the state of introducing automatic
coding styling.
https://bugreports.qt.io/browse/QTCREATORBUG-22149?jql=text%20~%20%22linter%22

https://bugreports.qt.io/browse/QTCREATORBUG-21877?jql=text%20~%20%22coding%20style%22




чт, 17 окт. 2019 г. в 23:13, Kyle Edwards via Development <
development at qt-project.org>:

> On Thu, 2019-10-17 at 20:01 +0000, Martin Smith wrote:
> > But that argues for not allowing the comma.
> >
> > QObject* x;
> > QObject* y;
> >
> > I've always done it that way.
>
> +1 for not allowing the comma. It's not as much of an issue for simple
> types (int x, y), but combining it with pointers and references
> introduces ambiguity and makes the code less readable - and readability
> is, IMHO, far more important than saving a few keystrokes.
>
> Kyle
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20191017/e3e63dcc/attachment.html>


More information about the Development mailing list