Results 1 to 2 of 2

Thread: error variable not declared

  1. #1
    Join Date
    Sep 2008
    Posts
    84
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default error variable not declared

    hi..
    In .h file I have declared
    Qt Code:
    1. union Uni1{
    2. int a_data;
    3. float b_data;
    4. }UTemp
    To copy to clipboard, switch view to plain text mode 

    In .cpp I want to access the variables in the union i.e UTemp.a or UTemp.b;

    But while compiling error is generated :

    error: a_data has not been declared.

    error: a_data has not been declared.
    Pls help
    Last edited by jpn; 4th December 2008 at 19:35. Reason: missing [code] tags

  2. #2
    Join Date
    Oct 2008
    Location
    Brazil, Sao Paulo - SP
    Posts
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: error variable not declared

    Your error must be related to any other thing.
    I created the file test.h:
    Qt Code:
    1. union Uni1{
    2. int a_data;
    3. float b_data;
    4. }UTemp;
    To copy to clipboard, switch view to plain text mode 
    and the test.cpp:
    Qt Code:
    1. #include "test.h"
    2.  
    3. int main(int, char**)
    4. {
    5. UTemp.a_data = 10;
    6. UTemp.b_data = 3.5f;
    7. return UTemp.a_data;
    8. }
    To copy to clipboard, switch view to plain text mode 

    compiled through:
    g++ test.cpp

    There were no error complains and the a.out output file was correctly generated. You haven't forgot the ';' after UTemp declaration, have you?

    Cheers
    Last edited by jpn; 4th December 2008 at 19:35. Reason: missing [code] tags

Similar Threads

  1. Installation on Fedora Core 4
    By jcr in forum Installation and Deployment
    Replies: 3
    Last Post: 29th January 2009, 01:34
  2. nmake error during .pro compiling
    By mattia in forum Installation and Deployment
    Replies: 5
    Last Post: 18th June 2008, 10:15
  3. Just for fun game
    By vermarajeev in forum Qt-based Software
    Replies: 6
    Last Post: 13th December 2007, 21:52
  4. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  5. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.