Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. error: C4430 and error: C2440:
Forum Updated to NodeBB v4.3 + New Features

error: C4430 and error: C2440:

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 5 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VBsFAN
    wrote on last edited by tekojo
    #1

    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'

    JonBJ aha_1980A 2 Replies Last reply
    1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What compiler are you using ?

      What is this UM_description structure ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      V 1 Reply Last reply
      1
      • BuckwheatB Offline
        BuckwheatB Offline
        Buckwheat
        wrote on last edited by
        #3

        @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.

        Dave Fileccia

        1 Reply Last reply
        0
        • V VBsFAN

          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'

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @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".

          1 Reply Last reply
          1
          • SGaistS SGaist

            Hi and welcome to devnet,

            What compiler are you using ?

            What is this UM_description structure ?

            V Offline
            V Offline
            VBsFAN
            wrote on last edited by
            #5

            @SGaist

            Hi,
            I used the GT creator with Visual Studio 2017

            JonBJ 1 Reply Last reply
            0
            • V VBsFAN

              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'

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @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.

              Qt has to stay free or it will die.

              1 Reply Last reply
              0
              • V VBsFAN

                @SGaist

                Hi,
                I used the GT creator with Visual Studio 2017

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @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....

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved