Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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);
printf(strTemp);

thanks for your help really appreciated.

thanks

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);
to
this :strTemp.Format("cConfig.strSource= %-20s\n",static_cast<wchar_t*>,cConfig.strSource);
Posted
Updated 16-Sep-20 0:02am
Comments
CPallini 16-Sep-20 2:22am    
Probably you are compiling the project using a different character set (e.g. UNICODE instead of ANSI). Check such setting in Visual Studio IDE.

You're casting "cConfig.strSource"; you show a "coma" before it and that is invalid. Look at the MS example again.
 
Share this answer
 
Comments
Marc_Moi 15-Sep-20 20:38pm    
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 15-Sep-20 20:42pm    
Ok I saw what you mean .. Now I have another error mentionning that no suitable conversion Function from CString to wchar_t.. dam ...
[no name] 15-Sep-20 20:46pm    
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 15-Sep-20 21:04pm    
yes visual studio 2019 updated to the last version
Marc_Moi 15-Sep-20 21:05pm    
I did that it created a backup folder but still can't do nothing with the file left.
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900