Error (active) E0167 argument of type "const char *" is incompatible with parameter of type "char *"

I'm getting the above error in Visual Studio 2019. I'm posting a link to two screen shots so you can see what I'm talking about. I'm happy to post code as soon as I find out what you guys need.

The first screen shot is the original error. You'll notice, however, in the second screen shot the error changed to

Error (active) E0144 a value of type "const char *" cannot be used to initialize an entity of type "char *const"

When I did Peek Definition on do_flee
Since you're already ignoring the 2nd parameter in do_flee, you can simply do
void do_flee(char_data *ch, const char *)

if you were going to use it, working with string literals directly is annoying. it is a lot easier to do this:

const int smallest_allowed_size{20}; //whatever size
char mt[smallest_allowed_size] = "";
foo(mt); //this works, you pass in a char*, not a const char* now
is there a reason you want to use C strings?
Last edited on
This game was written 10 years ago. I'm dusting it off to play it again and make it better. I'm also dusting off my rudimentary C++ knowledge so this is a learning project of sorts. Strangely, I gave this a go about 5 years ago and had it up and running in VS 2017.

salem c:
I made the change you suggested but the build still failed. If you weren't going to use a second parameter anyway why even include it in the definition to begin with? Why was it written this way?

My main goal with this project it so make this code better. I'll try to figure out a way to incorporate the changes you have suggested.
older compilers tolerated what you were doing, using char* off string literals, but stricter rules prevent it now. its probably possible to lower the compilers complaints to take it, if you have too many to fix.

if your goal is to fix it up nice, then moving to c++ <string> is the way to go. It solves a great many problems, but may be too much to take on.
Last edited on
So back to my original question. Is there a way to get this to compile in the meantime? Any suggestions on changing settings to not be so strict?

Just glancing through the errors almost all of them (like 2600) are some form of:

can't convert from const char[*] to char *

Could you elaborate on your original post and how to implement it?
Last edited on
Is there a way to get this to compile in the meantime?
I don't think so with VS 2019. You can disable warnings, but not errors.
Maybe some old compiler might work.
Is the source code somewhere available ?
I think the implicit const char * -> char * is configurable in MSVC.
I'm sure there has to be a way to compile this in VS 2019. It is, afterall, a C++ program that has compiled on previous versions of VS. It may be a matter of settings or changing the code but I'm confident it can be done.

Here's my email. Reach out and I'll send you, or anyone else that's interested, the source code

Can you elaborate? Are you using MS Visual C++ and MS Visual Studio interchangeably?
"MSVC" is usually used to refer to the compiler used by Visual Studio. If we're being technical, its name is CL.
The /permissive option enables that implicit casting, as well as other abuses old code used to do and old compilers used to permit.
Last edited on
g++ supports it as well, by default actually. You have to tell it to be picky.
I read the info on permissive standards. I changed mine to /permissive and the number of errors dropped down to 38.

Thanks everyone!
Topic archived. No new replies allowed.