Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. what to do to avoid this error: invalid conversion from 'void*' to 'char*' [-fpermissive] in qt ?
Forum Updated to NodeBB v4.3 + New Features

what to do to avoid this error: invalid conversion from 'void*' to 'char*' [-fpermissive] in qt ?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 3.6k Views
  • 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    Below line give error when i convert my c program in qt
    pFileBuffer = malloc(st.st_size);
    // error: invalid conversion from 'void*' to 'char*' [-fpermissive]

    my c code is :

          int nSourceFile;
            struct stat st;
            long n;
            int nSeconds;
            unsigned int nResult;
            char *pFileBuffer;
    
            stat(SOURCE_FILE,&st);
            printf("source file '%s', size = %d\n\r",  SOURCE_FILE, st.st_size);
            if((nSourceFile= open(SOURCE_FILE,O_RDONLY))<  0)
            {
                printf("can not open data classes source file \n\r");
                exit(1);
            }
    
            pFileBuffer = malloc(st.st_size);
            
            if (!pFileBuffer)
            exit(1);
            
            read(nSourceFile, pFileBuffer, st.st_size);
            ::close(nSourceFile);
            qDebug()<<pMainApp.ObjSettings.ObjFuelCheck.gauge_execute_fs(pMainApp.ObjSettings.ObjFuelCheck.nI2CId, pFileBuffer);
    
            free(pFileBuffer);
    
    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      Qt embedded developer
      wrote on last edited by
      #2

      By writing below type casting solved this error
      pFileBuffer =(char *) malloc(st.st_size);

      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