C++ compiler error c4430 “c++ doesnt support default int” [closed]

冷暖自知 提交于 2019-12-07 03:31:53

问题


Hi im trying to define an alias called USHORT.

    // *****************
// Demonstrates typedef keyword
#include <iostream>

typedef unsigned short int USHORT;  // typedef defined

main()
{
USHORT  Width = 5;
USHORT Length;
Length = 10;
USHORT Area  = Width * Length;
std::cout << "Width:" << Width << "\n";
std::cout << "Length: "  << Length << std::endl;
std::cout << "Area: " << Area;
}

I keep getting a compiler error saying:

Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\naqvi-home\documents\justit\c++\w1\cp1\list0304.cpp 8 1 ConsoleApplication3

Thanks

Ray


回答1:


It has nothing to do with your typedef. The problem is that you haven't given a return type for main:

int main()
{
  // ...
}

A function must have a return type. The main function must return int.




回答2:


I don't believe you need the extra int in the typedef, I thought from memory unsigned short (by default) is an int.




回答3:


You can easily look up the explanation for the error, by googling the error code. E.g. googling for 'C4430' would lead you here. The reason is, as others have stated, that you haven't declared the return type for main function.



来源:https://stackoverflow.com/questions/15186416/c-compiler-error-c4430-c-doesnt-support-default-int

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!