Click here to Skip to main content
14,636,013 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all,

I have this old program that was really usefull for my company. When using it it's crashing everytime.

I opened the code and I get the error code C6284 on this line

strTemp.Format("cConfig.strSource= %-20s\n", cConfig.strSource);

but I really don't know how to fix this so it would work again.

I have 49 error like this.
I'm trying to find the solution on the net but it's not working for me I also tried to debug but it wont compile.

here's another line that has the same code issue.

strTemp.Format("\nFile SENDER= %-20s RECEIVER= %-20s", fileSender, fileReceiver);

thanks for your help really appreciated.


What I have tried:

I tried something found on the net in the doc microsoft on this link
C6284 | Microsoft Docs[^]
but I can't make it to work
this strTemp.Format("cConfig.strSource= %-20s\n", cConfig.strSource);
this :strTemp.Format("cConfig.strSource= %-20s\n",static_cast<wchar_t*>,cConfig.strSource);
Updated 5 days ago
CPallini 5 days ago
Probably you are compiling the project using a different character set (e.g. UNICODE instead of ANSI). Check such setting in Visual Studio IDE.
Rate this:
Please Sign up or sign in to vote.

Solution 1

You're casting "cConfig.strSource"; you show a "coma" before it and that is invalid. Look at the MS example again.
Marc_Moi 5 days ago
sorry I don't understand what you mean.. I've been looking at this for the pass 3 hrs trying thing that won't work. and I'm only at error 1 I have 49 to do . :(
Marc_Moi 5 days ago
Ok I saw what you mean .. Now I have another error mentionning that no suitable conversion Function from CString to wchar_t.. dam ...
Gerry Schmitz 5 days ago
Are you using Visual Studio? Is there a solution or project file? If you open one of those files in VS, sometimes VS will do an "upgrade" for you. Sometimes ...
Marc_Moi 5 days ago
yes visual studio 2019 updated to the last version
Marc_Moi 5 days ago
I did that it created a backup folder but still can't do nothing with the file left.
Marc_Moi 5 days ago
to see the file I have to use the blend version of visual studio.
Stefan_Lang 5 days ago
While a coma is a sure source of errors, I suspect you actually meant "comma" ;-p
Gerry Schmitz 5 days ago
Argh. I don't say "come Ma" either. :o)
Rate this:
Please Sign up or sign in to vote.

Solution 2

static_cast (or C-style cast) is almost always(*) the wrong approach! The error explicitely states that the type being used is not compatible to the type being expected, and that is a sure indication that you need an actual conversion function, not a type cast!

In case of CStrings, what you need is checking the available functions and using them properly. As indicated here[^], if strSource is of type CString, you should use the GetString() method on it, not cast it to a type that it is not compatible with.

(*): The exception is using a type cast to PCXSTR, because that cast is overridden in the CString class to implicitly perform the required conversion.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100