PDA

View Full Version : Reopening an old file- "C++ does not support default-int"



arhowk
25th December 2016, 21:17
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


#ifndef DGUIREADER_H
#define DGUIREADER_H

#include <QString>
#include "model/triggers/dguifile.h"

class DGUIReader
{
public:
DGUIReader();
DGUIFile OpenFile(QString *);
WriteFile(DGUIFile *);

};

#endif // DGUIREADER_H


The error is pointing to this line

WriteFile(DGUIFile *);

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


This is the way my code was running previously and it worked perfectly fine
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

d_stranz
25th December 2016, 21:45
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.

arhowk
25th December 2016, 21:56
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.

d_stranz
27th December 2016, 00:54
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.