error: C4430 and error: C2440:



  • I get the following error when building with gt 5.10. I would appreciate your feedback.

    error: C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    error: C2440: 'initializing': cannot convert from 'initializer list' to 'int'

    The piece of code that causes the above error. I used the type specifier double and float but still it did not work.

    unsigned char UM;	//All input-output uses this unit of measure: only the grid has its own specific unit of measurement.
    UM_description;
    UM_descriptions[UM_DESCRIPTION_COUNT]=
    {
        //Use as a base unit the 1/100 of thou (10 ^ -5 inch) which corresponds to 0.254 micrometers
        {"mm",	3937.0,	3},	//1000.0,		//0
        {"inch",	100000.0,	5},	//25400.0,		//1
        {"thou",	100.0, 2},	//25.4,			//2
        {"metre",3937000.0,6},	//1000000.0,	//3
        {"cm",	39370.0,	4},	//10000.0,		//4
        {"micron",3.937,	0}	//1.0,		//5
    };
    

    I get the following error when I used the float specifier for UM_descriptions

    error: C2440: 'initializing': cannot convert from 'initializer list' to 'float'

    I get the following error when I used the double specifier for UM_descriptions

    error: C2440: 'initializing': cannot convert from 'initializer list' to 'double'


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What compiler are you using ?

    What is this UM_description structure ?



  • @VBsFAN
    Hello and Welcome!

    I noticed you said "float" in your comment. Please add an 'f' to your initializer (eg. 10.0f). Some compilers require this to differentiate double and float.



  • @VBsFAN

    I used the type specifier double and float but still it did not work.

    Given that you're asking about compiler error messages, could we see the actual code you are compiling when you get a message? People post here who do all sorts of things....

    In a word, your syntax is wrong. Nothing to do with Qt.

    Your line which reads simply:

    UM_description;

    What is that line doing there, with no further reference to UM_description? If I didn't know better, I'd wonder whether you really mean...

    UM_description UM_descriptions[UM_DESCRIPTION_COUNT]=
    

    ...And then your whole initializer list might make sense.... Because as it is now, using float or double is going to make no difference anywhere. You're not understanding/specifying what that is an array of, and the compiler doesn't know, hence the message:

    error: C2440: 'initializing': cannot convert from 'initializer list' to 'int'

    To be specific, it's actually for your inner initializers. Compiler has told you it's expecting an array of ints. Instead it sees "an initializer list".



  • @SGaist

    Hi,
    I used the GT creator with Visual Studio 2017



  • @VBsFAN

    If you want us to help you with compiler errors, you have to post the exact code that causes the compiler error.

    A snippet is not enough. Please provide a minimal example that we can actually compile too.

    Thanks.



  • @VBsFAN
    In my response above I have already told you what is wrong: your code is wrong, you have no type, or an incorrect type, for your UM_descriptions array. You can ask all the questions you want, but until you fix that it's not going to compile, anywhere....


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.