Results 1 to 4 of 4

Thread: Reopening an old file- "C++ does not support default-int"

  1. #1
    Join Date
    Dec 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Reopening an old file- "C++ does not support default-int"

    Hello,

    I have a project that I was working on about 6 months ago and was looking to return to since I have an increase of free time. After re-installing Qt and my C++ environment, I tried to run my code and I was met with one error (repeated ~200 times)

    D:\Code\Github\D2GUI\model\triggers\dguistructurev alue.h:16: error: C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    D:\Code\Github\D2GUI\model\triggers\dguistructurev alue.h:16: warning: C4183: 'append': missing return type; assumed to be a member function returning 'int'

    I spent quite a while google searching and the only case I've seen this error come up is if the type that a function returns does not exist/has not been declared yet (circular dependency style issues)

    An example of the code that produces this error is this

    Qt Code:
    1. #ifndef DGUIREADER_H
    2. #define DGUIREADER_H
    3.  
    4. #include <QString>
    5. #include "model/triggers/dguifile.h"
    6.  
    7. class DGUIReader
    8. {
    9. public:
    10. DGUIReader();
    11. DGUIFile OpenFile(QString *);
    12. WriteFile(DGUIFile *);
    13.  
    14. };
    15.  
    16. #endif // DGUIREADER_H
    To copy to clipboard, switch view to plain text mode 

    The error is pointing to this line
    Qt Code:
    1. WriteFile(DGUIFile *);
    To copy to clipboard, switch view to plain text mode 

    My only guess is that the error is because I didn't define the return type, but

    1. This is the way my code was running previously and it worked perfectly fine
    2. I made a new project using this same style of ignoring the return type to assume int and it worked perfectly fine


    I was wondering if there was some Qt configuration option I messed up for this project or something... I would go through and convert every function to "void WriteFile(..." but considering that this error should not show up I'd rather try to resolve it if it is easily resolvable or if there is another underlying problem with my Qt configuration

    Thanks, ~Arhowk

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Reopening an old file- "C++ does not support default-int"

    I was wondering if there was some Qt configuration option I messed up
    No, the error message says it all: C++ does not support default int. All functions must have their return types declared. There is no return type declared for WriteFile. If this worked at some time in the past, it was probably because the C++ compiler you were using at the time was not compliant to the C++ standard.

    This error has noting to do with Qt or your Qt configuration. It's a compile-time error in -your- code.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Dec 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Reopening an old file- "C++ does not support default-int"

    Okay, yes, nevermind. I messed up my test case because I forgot to include the header file so it never compiled and it gave me the same error when included. I don't know how my compiler difference made a difference when that standard was implemented in 2005. I guess I'll have to go through and add void return types to all my functions. Thanks.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Reopening an old file- "C++ does not support default-int"

    As far as I know, the C language uses "int" as the default return type for functions where a return type is not declared. Since most C++ compilers are written to also compile C, some of them allowed this for C++ methods even though it was not compliant with the standard. I do not know when Microsoft made their compilers compliant with this part of the standard - probably after Stan Lippman joined in 2001.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Default QFileDialog to "This PC" or "My Computer"
    By JayKemper in forum Qt Programming
    Replies: 1
    Last Post: 18th June 2015, 22:12
  2. Replies: 1
    Last Post: 15th June 2010, 06:49
  3. Replies: 3
    Last Post: 15th February 2010, 17:27
  4. Replies: 3
    Last Post: 8th July 2008, 19:37
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.