Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8943689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:50:30+00:00 2026-06-15T11:50:30+00:00

I try to compile with gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC) The

  • 0

I try to compile with gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC)
The input file has a const char :

#include <stdio.h>
#include <stdlib.h>
#include "textfile.h"
...
const char * vs=NULL;
vs = textRead("myfile.file");
const char * vv = vs;
free(vs);

This chars vars are used into main cpp program and will be fill with text.

I use in header one function textRead to load the data from myfile.file

I got this error ( I thinking is a cast conversion ) but don’t know where I make mistakes.

warning: deprecated conversion from string constant to ‘char*’
error: invalid conversion from ‘const void*’ to ‘void*’

first warning is about vs = textRead(“myfile.file”);
second error is about free(vs);

What is wrong with my code ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:50:31+00:00Added an answer on June 15, 2026 at 11:50 am

    You haven’t posted what the textRead function looks like, so I’m assuming its signature is as follows:

    void *textRead( char *filename );
    

    textRead is taking the name of a file to read, it doesn’t (shouldn’t) need to modify the string passed to it, so change textRead to

    void *textRead( char const *filename );
    

    If you cannot modify the function, change your code to

    char filename[] = "myfile.file";
    vs = textRead( filename );
    

    The error message about free is pretty self-explanatory, free expects a void * and you’re passing it a const pointer instead. I don’t see any reason why vs needs to be a const char * instead of a char *. Change that and the error will go away.

    Also, I don’t understand why you’re making a copy of vs right before freeing it, but maybe you haven’t posted stuff that happens in between those 2 lines.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to compile code, that beggins with: #include<stdlib.h> #include<GL/gl.h> #include<glaux.h> with command: cc
When I try to compile my program on ubuntu using gcc, i get these
I'm using code blocks with gnu gcc compiler. But when I try to compile
The short version: I try to compile MAGMA and get complains about missing symbols:
On my computer I have Ubuntu 10.10 with gcc 4.4.4. I try to compile
When I try to compile this file by issuing the command, g++ qr.cpp -o
Consider the code below. I don't understand why my GCC compiler does not try
When I try compile with maven 3.0.4, Eclipse give me this error: Failed to
I try to compile and link my application in 2 steps : Compiling: g++
When I try to compile this code: struct BasicVertexProperties { Vect3Df position; }; struct

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.