[Qt-creator] C++ parser and anonymous union, structs and classes

eike.ziller at nokia.com eike.ziller at nokia.com
Mon Dec 12 08:51:33 CET 2011


On 12 Dec 2011, at 01:37, ext Alexander 'hatred' Drozdoff wrote:

> Hi guys!
> 
> I have structure in my project, that contain anonymous unions (also tried with structs and classes
> - same result) and autocompletion for them look like incorrect. Example below:
> ~~~ cut here ~~~
> #include <stdio.h>
> 
> struct st1 
> {
>  union
>  {
>    unsigned long ul;
>    unsigned char raw[8];
>  };
> 
>  // another fields...
> };
> 
> struct st2
> {
>  union
>  {
>    unsigned long ul;
>    unsigned char raw[8];
>  } long_bytes;
> 
>  // another fields...
> };
> 
> 
> int main()
> {
>  struct st1 st1;
>  struct st2 st2;
> 
>  // correct
>  st1.ul            = 0xFFFEFDFC;
>  // but:
>  st2.long_bytes.ul = 0xFFFEFDFC;
>  // and here error:
>  ///st2.ul            = 0xFFFEFDFC;
>  // but Qt Creator show 'ul' in auto-complete dialog for 'st2.'
> 
>  return 0;
> }
> ~~~ cut here ~~~
> 
> 
> in this example in structure 'st1' we can access to fields 'ul' and 'raw' directly - it valid, and
> this fields displayed in autocompletion list - it valid. But, in structure 'st2' we can't access to
> fields 'ul' and 'raw' directly (compiler exit with error) only via 'long_bytes' - it valid, but
> autocomplete list shows all fields:
> ul
> raw
> long_bytes
> 
> it look like incorrect. I try to look in to code, but I don't understand it currently and can't
> provide fix.
> 
> So, should I report issue, or it is 'feature'? :-)

A bugreport already exists:
https://bugreports.qt.nokia.com/browse/QTCREATORBUG-3610

Br, Eike

> Also, if I rewrite structure 'st2' as below (added type-name for union '__u1__'):
> ~~~ cut here ~~~
> struct st2
> {
>  union __u1__
>  {
>    unsigned long ul;
>    unsigned char raw[8];
>  } long_bytes;
> 
>  // another fields...
> };
> ~~~ cut here ~~~
> 
> Autocomplete list shows correctly, without 'ul' and 'raw' fields.
> 
> -- 
> WBR
> Alexander Drozdov
> FIDO: 2:5045/41.84
> Site: http://hatred.homelinux.net
> Site: http://archlinux.org.ru
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator

-- 
Eike Ziller
Principal Software Engineer

Nokia, Qt Development Frameworks

Nokia gate5 GmbH
Firmensitz: Invalidenstr. 117, 10115 Berlin, Germany
Registergericht: Amtsgericht Charlottenburg, Berlin: HRB 106443 B
Umsatzsteueridentifikationsnummer: DE 812 845 193
Geschäftsführer: Dr. Michael Halbherr, Karim Tähtivuori




More information about the Qt-creator mailing list